Last active
December 15, 2015 05:48
-
-
Save tunaranch/5211210 to your computer and use it in GitHub Desktop.
Quick and dirty sh script to copy a file's location to clipboard, so you can paste it into an scp command. OS X only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#Usage: coordinates.sh foo.txt | |
# realpath function from http://stackoverflow.com/questions/3572030/bash-script-absolute-path-with-osx | |
USER=`whoami` | |
IP=`ifconfig en0 inet | grep "inet" | awk -F\ '{print $2}'` | |
realpath() { | |
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" | |
} | |
PATH=$(realpath "$1") | |
COORDS="${USER}@${IP}:${PATH}" | |
printf "${COORDS}" | /usr/bin/pbcopy | |
echo "Copied scp coordinates [${COORDS}] to clipboard" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment