Connect Terminal with the clipboard and the Finder
pbcopy, pbpaste and open bridge the command line and the rest of the Mac.
Works on: macOS Big Sur 11 and later · checked on macOS Golden Gate 27
Published: · Source: SS64
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
Get back something you copied earlier
In macOS Tahoe, Spotlight keeps a searchable history of what you copy.
Park files on a floating shelf while you drag
Shake the pointer mid-drag and Dropover opens a temporary shelf, so you can pick things up now and drop them somewhere else later.
Rename a batch of files in one go
The Finder can replace text, add text or number a whole selection of files at once.