When using GNU Screen we can work with scrollback buffer also known as "copy mode" using the Ctrl+a+[
command.
In there we can copy text to the copy buffer by pressing space
selecting the text and pressing space
again.
Is there some way to copy this text from screen copy buffer to the X clipboard?
In my case I'm using Ubuntu 12.04 with gnome and Xorg.
To scroll up within a screen window, use this command: CTRL+a then ESC, #Press CTRL KEY and 'A' KEY together and then hit the ESC KEY #to scroll using the arrow keys hit ESC again to exit.
You can use a CLI clipboard tool like xsel
or pbpaste
and the cat
utility to grab contents from STDIN. The steps on Linux with xsel
are as follows:
cat | xsel -b
xsel
didn't report any error, now dump screen's copy buffer to STDIN: Ctrl+a+]
cat
to terminate it: Ctrl+d
At this point, the contents of the screen copy buffer should be in your clipboard.
EDIT: As with all X programs, xsel
needs to know how to contact your X server in order to access the clipboard. You should have your DISPLAY
environment variable set appropriately.
This answer works for only a scenario where your end target is to paste the copied buffer contents immediately.
The simplest way to do this is by splitting your screen into two regions. You can do this by hitting CTRL+a then |'This is not an i. It is the PIPE sign on your keyboard'
Hit CTRL+a then TAB to switch to the second region, CTRL+a then c to create a new session in the second region.
If you want to copy from nano and paste in terminal, open up the file in nano on the left region, hit CTRL+a then ESC, scroll to the start point of your copy location and hit SPACE, select the text by scrolling to the end point and hit SPACE again to mark copy.
Now, all you have to do is hit CTRL+a then TAB to switch to the region on your right and hit CTRL+a then ].
Your text will be written out to the command line. Note that you can also check for hardcopy option if you want to write directly to file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With