Copy To Clipboard In MacOS Terminal

Image for post
Image for post

Copy From Terminal

Copy the output of something to the clipboard with pbcopy using the “pipe” character |:

$ pwd | pbcopy

You now have the “working directory” of that terminal in the clipboard.

Go ahead.

Cmd + V that sucker into another window and you’ll see something like:

/Users/username

Paste To Terminal

Guess which command will paste to the terminal???

You guessed it: pbpaste.

If you still have your working directory in the clipboard, when you run pbpaste you should see:

$ pbpaste
/Users/username

Ain’t that fun?

Written by

Front-end Web Developer. Language lover. Traveler. Dude.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store