Ubuntu – Copy current terminal prompt to clipboard


Is there a way to copy the currently written content of the bash prompt? Say I wrote:

ping www.google.com

so that the lines in terminal looks like:

petr@sova:~$ ping www.google.com

and didn't hit return yet. I want to copy that text to clipboard. Is that possible?

The usual usecase would be hitting up several times and finding a command which I want to copy.

Best Answer

To cut, press ctrl+u. To paste, use ctrl+y. This copies whole line to bash clipboard. If you're using X and default Ubuntu terminal, you can use your mouse to mark contents and press ctrl+shift+c to copy, and ctrl+shift+v to paste.

Related Question