yank: copy terminal text to clipboard

As the name suggests, yank is a tool to copy text. The usual way to copy from the terminal is to select the text and press <Ctrl-Shift-c>. yank is an alternative where you can pipe (or redirect) the output to yank (i.e., it reads from stdin) and then use keyboard shortcuts to move between output text and select the text you want.

It’s difficult to comment on where yank is a better in usability (than the traditional way) but it’s a cool alternative.


To install yank on Ubuntu, run:

$ sudo apt-get install xsel
$ git clone https://github.com/mptre/yank
$ cd yank
$ make
$ sudo make install


The animation above shows the usage well. Pipe the output to yank. The default keys to move between text are <Ctrl-n> and <Ctrl-p> and the only way to change those is by editing the code directly.

yank man page comes with a number of examples to explain the several use cases. Run:

$ man yank

Leave a Reply

Your email address will not be published. Required fields are marked *