Unix Trick: PBCopy

Last week I blogged about my favorite Unix trick. Today I’m going to look at another – PBCopy.

This one only exists in OSX – it allows you to interact with the clipboard through the command-line. For example, if you want to copy the contents of your ssh key to the clipboard you can do the following:

pbcopy < ~/.ssh/id_rsa.pub

You can also pipe into it, so the following will put the contents of the readme file on the clipboard:

cat README.md | pbcopy

Happy coding.

Tags: OSX, Unix

  1. Olivier says:

    This is useful.
    The linux equivalent is xclip:

    echo “Hello !” | xclip -selection clipboard

  2. Nice! I knew there was an equivalent, but I’ve never bothered to look it up.