Copy the Current Path from Terminal

  • Mac OSX

Mac OSX

sample code 1

pwd | pbcopy

The current path has been copied to the clipboard,Paste it anywhere.

You can use this way:

alias cppwd='pwd | pbcopy'

then

cd ~
cppwd

The current path has been copied to the clipboard,Paste it anywhere.

sample code 2

pwd | tr -d '\n' | pbcopy

alias

alias cppwd='pwd | tr -d "\n" | pbcopy'

then

cd ~
cppwd

The current path has been copied to the clipboard,Paste it anywhere.

Extension

How do I remove “Custom alias”

If you add a ‘alias cppwd="pwd|pbcopy"’. You can use this way:

unalias cppwd

unalias [aliasname]


Have a good time. :stuck_out_tongue_winking_eye: