OS X: Manipulating the Clipboard via Command Line

March 5, 2010
appleunix

So I somehow just found out that you can manipulate OS X’s clipboard via command line. The utility that does it is called pbcopy (and pbpaste).

[bash]echo "Lorem ipsum dolor sit amet" | pbcopy[/bash]

Now, go into any OS X application and perform the paste (⌘-v) command and you’ll have the content you placed there via command line. Or you can use the related pbpaste to output your content.

[bash]pbpaste (to wherever)[/bash]

pbcopy

Related

[ pbcopy / pbpaste | Mac Developer Manual > ]

supporting = loving

For 29.5299 years I've been creating ad-free technical tutorials and essays here. 3,045 pieces and counting.

It's a one-person effort that's also my livelihood. If it makes your day easier or more pleasant in any way, please consider supporting the work with a monthly or one-time donation.

It helps me make more content, and is deeply appreciated as well. 🫶🏼