Skip to content

Instantly share code, notes, and snippets.

@bitaxis
Last active October 31, 2018 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitaxis/a870ab7f90c0442a1c61e22c5a206053 to your computer and use it in GitHub Desktop.
Save bitaxis/a870ab7f90c0442a1c61e22c5a206053 to your computer and use it in GitHub Desktop.
For OS X, copy path of directory or file to clipboard
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