Last Updated: February 25, 2016
·
381
· anthonysutardja

Copying working directories

I use this nifty trick in OSX to copy the working directory of one term window to the others.

In the working term window:

pwd | pbcopy

In the term windows you wish to change the directory to the targeted working directory:

cd `pbpaste`

Note that this will only work if you don't copy something into OSX's clipboard before pasting.

To make life simpler for myself, I aliased these commands.

alias cpwd='pwd | pbcopy'
alias ppwd='cd `pbpaste`'

You must use single quotes if you alias these commands; double quotes will cause the inline execution to execute when the command is being aliased.