I'm trying to figure out a way to copy the current text in a command line to the clipboard WITHOUT touching the mouse. In other words, I need to select the text with the keyboard only. I found a half-way solution that may lead to the full solution:
Ctrl+a - move to the beginning of the line.
Ctrl+k - cuts the entire line.
Ctrl+y - yanks the cut text back.
Alternatively I can also use Ctrl+u to perform the first 2 steps.
This of course works, but I'm trying to figure out where exactly is the cut text saved. Is there a way to access it without using Ctrl+y ?
I'm aware of xclip
and I even use it to pipe text straight to the clipboard, so I was thinking about piping the data saved by Ctrl+k to xclip
, but not sure how to do it.
The method I got so far is writing a script which uses xdotool
to add echo
to the beginning of the line and | zxc
to the end of the line, and then hits enter (zxc
being a custom alias which basically pipes to xclip
). This also works, but it's not a really "clean" solution.
I'm using Cshell if that makes any difference.
EDIT: I don't want to use screen
as a solution, forgot to mention that.
Thanks!