Shell to Clipboard

December 13th, 2005

I figured it’d be nice to be able to print output from the terminal/shell to OS X’s general clipboard. So after a little digging I found these two commands:

pbcopy - copy to the clipboard.
pbpaste - paste from the clipboard.

Piping output should come in handy, ie:

pwd | pbcopy

will print the full path of the current directory directly to the cliboard. Or :

ls | pbcopy

for a list on the contents of the current directory.

Found over at Ted’s Ted’s Macintosh Tips and Tricks, which is well worth a butchers.