Last active
October 31, 2018 13:04
-
-
Save bitaxis/a870ab7f90c0442a1c61e22c5a206053 to your computer and use it in GitHub Desktop.
For OS X, copy path of directory or file to clipboard
This file contains hidden or 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
function cpd { | |
if [ "$1" == "" ]; then printf `pwd` | pbcopy; return 0; fi | |
if [ -f "$1" ]; then printf `pwd`/$1 | pbcopy; return 0; fi | |
if [ ! -d "$1" ]; then echo "$1: No such directory"; return 1; fi | |
printf `pwd` | pbcopy | |
popd > /dev/null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment