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 > ]

Reader-supported

For roughly 29.7801 years I've written here, ad-free—3,078 essays and tutorials and counting. If it's useful to you, a monthly or one-time donation keeps it going. 🫶🏼