The MacOS shell is very powerful to let you solve all your problems without making use of graphical tools. However, I am pretty sure an awful lot of users are not aware of some wonderfully useful commands which are almost entirely unknown to the community at large. In this post, I will show you two of these forgotten commands are
pbpaste. Let’s take a quick look at what they can do.
This command allows you to copy text from stdin into the clipboard1 buffer. Trivial example:
echo 'Hello World!' | pbcopy
“Hello World!” is now in your clipboard.
Pastes from your clipboard to stdout. Trivial example:
This will echo the contents of your clipboard. If you’re following along you’ll see “Hello World!”.
Some use cases
What can’t you do! Oh, you want examples? Well…
- You could grab the output of a grep/awk/sed to paste into IM/IRC.
- You could use a macro tool (like iKey, QS, etc) to create text modifying workflows that grab highlighted text, manipulate it, and replace it inline.
- You could pull changelogs from svn into the clipboard when tagging for release so you could email them to coworkers.
Let me know what amazing things you come up with to enhance your own productivity!
- or pasteboard, hence the prefix “pb”