Quick copypasta with xclip

Here's a quick tip for making copy-paste a little easier on a laptop where it's a pain in the ass to use the trackpad, or for those command-line junkies like myself who just don't want to take their hands off the keyboard.

By on

I’ve been working with PEG.js online to create a little domain-language for the devs at work. It’s nice to see it evaluate the grammar in real time, but I also wanted to save each change I made to the file system in order to document it with some unit tests. And I’m using a laptop with no external mouse or keyboard.

So there’s a neat little copy-paste utility for managing clipboard selections in X called xclip. You can install it in Debian-based systems with the following command:

sudo apt-get install xclip

To put a file into the clipboard, call:

xclip -sel clip < file/to/copy.txt

To transfer your clipboard to a file, run:

xclip -o > file/to/overwrite.txt

Have fun re-training your hands not to ctrl-v every time you want to paste!