You're viewing a single post. I have much more to say! The main blog page is a good starting point.

Command line and the clipboard

A few days ago I stumbled upon a question in a newsgroup: how to put text on the Gnome clipboard from the command line?

In response, I wrote a small Python script (using PyGTK) that can be used as a pipe in your command line scripts. It puts all data from stdin on the clipboard. For this to work, you will need the correct $DISPLAY environment variable set (which will be the case most of the time, but it doesn’t work from cron for example).

CLI lovers, download copy-to-clipboard here and rejoice!

Update: Sure, there’s also tons of other solutions like xclip and of course the script could be more like a one-liner, but I like to demonstrate the ease of use Python and PyGTK offer.