Ubuntu – Select/copy/paste in terminal using only the keyboard

command line

I'm looking for a way to select, copy and paste the text in the terminal completely without the mouse.

I've been using tmux until now, but I find its key combinations a bit complex for everyday use of copy & paste, and I'm now looking for alternatives.

Do you guys have any suggestions?

To be clear, this is not about piping to the clipboard but about selecting the text as it's possible in e.g. tmux!

Best Answer

Consider xclip, which is a command-line interface to the X clipboard, and is available with sudo apt-get install xclip.

You may have noticed that in Ubuntu, if you select some text and then press the middle mouse button, that text will get pasted into whatever input is in focus. xclip hooks right into that, so if you run seq 10 | xclip -i then middle-mouse somewhere, you'll paste the numbers 1 to 10. If you were to select my username then run xclip -o | cowsay, you'll get a cow saying the word "ymbirtt".