OS X: How can I copy the shell path to clipboard?

1

1

When working with files on my mac I employ a mixed approach of shell/finder or keyboard/mouse, similar to working with 4NT and Explorer on Windows.

One thing I use(d) extensively on Windows is to copy the path of the current directory to the clipboard. This is an extended feature of TakeCommand by JPSoft, on Windows.

Is there a way to copy the current path from the bash shell to the mac's clipboard, so I can use it in 'file open' and/or similar dialogues?

lexu

Posted 2011-01-10T07:09:20.193

Reputation: 1 822

Answers

2

printf "$PWD" | pbcopy

There's also the program pbpaste that pastes (pb = pasteboard, i.e. clipboard).


Use Cmd-Shift-G in open file dialogs to insert that path.


Thanks to Dennis Williamson for the printf hint.

Daniel Beck

Posted 2011-01-10T07:09:20.193

Reputation: 98 421

2printf "$PWD" | pbcopy or printf "$(pwd)" | pbcopy will eliminate the trailing newline. – Paused until further notice. – 2011-01-10T07:56:03.240