← All tips

Connect Terminal with the clipboard and the Finder

pbcopy, pbpaste and open bridge the command line and the rest of the Mac.

Three small commands save a lot of selecting with the mouse.

pbcopy puts whatever it receives on the clipboard, ready to paste into any app:

pbcopy < ~/.ssh/id_ed25519.pub   # copy a file's contents
ls ~/Desktop | pbcopy            # copy a command's output

pbpaste does the reverse and prints the clipboard, so you can save it or feed it to another command:

pbpaste > notes.txt

open does from Terminal what a double-click does in the Finder:

open .                     # this folder, in a Finder window
open report.pdf            # the file, in its usual app
open -a Safari page.html   # in a specific app
open -R report.pdf         # reveal it in the Finder

Related tips