Pipe commands/output directly into your clipboardFeb 18th, 2012 | By admin | Category: Linux / Freebsd
Ah, I had this thought today while running cat on a php file that it would really be nice if, instead of catting the file and then selecting the output in terminal, scrolling up, all the way up and copying it, I could just run cat on a file and have the output go directly to my clipboard. Well this is linux baby so OF COURSE you can do that because it just makes a whole lotta fricken sense.
I needed to go and installed a little program called ‘xclip’ and after that all I had to do was type: cat file.php | xclip and guess what’s sitting in my secondary clipboard? Ooh yea, the bloody contents of file.php.
The funny thing is that by default the input should go into my primary clipboard(ctrl+v) but it goes into my secondary clipboard instead(middle mouse-button). Anyways, to get around that all I need to do is type: cat file.php | xclip -selection c and it ends up in the primary clipboard.
Either way, this is definitely one of the damned coolest things I’ve discovered in linux for a while! Yay for efficiency!