xclip

Reviews

Please sign in or register to add your own review.

4 stars
A little-known Linux utility that's a small productivity booster

In 1994, Peter Salus summarized the Unix philosophy as follows:

  • Write programs that do one thing and do it well.
  • Write programs to work together.
  • Write programs to handle text streams, because that is a universal interface.

The small utility xclip should be viewed with that philosophy in mind. All it does is handle clipboard contents for you on the command line. You can output the contents of your clipboard(s), or put text in the clipboard. It’s in combination with other Unix-style utilities and input/output streams that this can become a very useful tool.

Say you have a bunch of text on a webpage and want to search/replace some terms. If you already have a terminal open, just pipe it through xclip. Or you have a large textfile you want to paste into an email. Again, no need to load the file or select anything manually – just cat filename | xclip will do the job. This is not a huge deal but one of those small things that make using Unix-like systems enjoyable. In the last 15 years, I’ve probably used xclip a few thousand times.

Note that by default, xclip uses the “primary” clipboard, the contents of which you can access with the middle mouse button. You can use the Windows-style Ctrl+C/Ctrl+V clipboard by specifying -selection clipboard (or creating an alias to that effect).