Mac OS X has the useful commands pbcopy
and pbpaste
. pbcopy
reads the contents of standard input into the clipboard; pbpaste
writes the contents of the clipboard to standard output. These commands aren’t part of the standard set of commands on Linux, but they’re easily added. Simply install the XSel program via a package management system or directly from source, then add these lines to ~/.bashrc
. Voilà! Easy commandline access to the clipboard.
alias pbcopy='xsel --clipboard --input' alias pbpaste='xsel --clipboard --output'