Script-fu: cat directly to X clipboard

April 10, 2009

Have you ever wanted to ‘cat’ a file directly to the clipboard? OF COURSE, why else would you be reading this sentence? Simply install ‘xclip’, which is simple also, if you are on ubuntu:

    sudo apt-get install xclip
Anything that you pipe to it goes to the X11 clipboard. Once there, you can just hit the middle mouse button to paste it where you want, just as if you had highlighted it. So you can do things like this:
    $ cat some.file | xclip
    $ nslookup somehost | xclip
    $ ./runsomeawesomescriptthatyouwanttheoutputintheclipboard.sh | xclip