Fiddling with X selections from shell scripts

I know of three command-line programs that will fiddle with the X selection (and/or the cut buffers) in a way that's useful for shell scripts: xsnarf from Smarasderagd's collection of X things , xcb , and xclip .

I use xsnarf for a variety of reasons, I think partly historical (in that I had it around well before I found the others); I'm jotting down the other two here partly so that I have the information handy the next time someone asks me about this.

You may reasonably ask why this is actually interesting. Here's why:

Shell scripts are the easy way to automate things on Unix. Doing things in X Windows sessions is no exception, but there you need some extra programs as building blocks. One of the important building blocks is some way to fiddle with the X selection (or the cut buffers); having this lets you set things up so that you can do things like select a URL in a terminal window and fire it into a browser.

Yes, yes, some terminal emulators have this specific feature built in now. Some ; making a shell script to do this means it works for anything that can make an X selection. Terminals. GNU Emacs. A help browser. Everything .

I would much rather set up a general facility, once, than run around repeatedly adding yet another feature to yet another program, and hoping that I wedged it into all of the ones I care about. It's a lot easier, for a start, and it scales much better.