How to copy GNU screen copy clipboard to clipboard

When using the GNU screen, we can work with the scroll buffer , also called the "copy mode using the command Ctrl+a+[ .

In this case, we can copy the text to the clipboard. by pressing space , selecting text and again pressing space .

Is there a way to copy this text from a screen buffer to the X clipboard?

In my case, I am using Ubuntu 12.04 with gnome and Xorg.

+43
linux terminal copy-paste gnu-screen gnome-terminal
Apr 19 '13 at 18:48
source share
6 answers

You can use the CLI clipboard tool like xsel or pbpaste and the cat utility to grab content from STDIN. The steps for Linux with xsel as follows:

  • Copy text from the screen session to the GNU screen copy buffer.
  • Run this command on screen: cat | xsel -b cat | xsel -b
  • If xsel did not report any error, now the copy buffer of the reset screen is in STDIN: Ctrl+a+]
  • Send EOF to cat to complete it: Ctrl+d

At this point, the contents of the screen buffer should be on your clipboard.

EDIT: as with all X programs, xsel needs to know how to contact your X server in order to access the buffer. You must have the appropriate DISPLAY environment variable.

+30
Apr 29 '13 at 19:25
source share

This answer applies to OS X.

After copying the desired text to the buffer of the GNU screen palette using the copy mode, do the following:

  • In any of your screen windows, enter pbcopy <enter> .
  • Then paste the text into the terminal using the GNU screen, paste the command ( Ctrl-a ] if you have not changed your escape key).
  • If the text does not end in a new line, press <enter> to insert it.
  • Finally, press Ctrl-d to call pbcopy to enter text into the system clipboard.

You can then paste the text elsewhere in OS X, as usual, using Command-v or the equivalent menu.

+7
Aug 18 '14 at 17:32
source share

There is an easier and less manual way to do this. On your screen .rc file add the following line:

 bindkey -m ' ' eval 'stuff \040' 'writebuf' 'exec sh -c "/usr/bin/pbcopy < /tmp/screen-exchange"' 

How to use the copy function:

  • screen -c path/to/screen/config.rc
  • Press Ctrl + A, then Esc to go to copy mode.
  • Scroll through the text buffer and find the place where you want to leave the start marker for copying, then press the spacebar.
  • Scroll down and select the text you want to copy. When you're done, press the spacebar again.
  • The text will now be on your clipboard.
+6
Dec 10 '16 at 0:18
source share

This answer only works for a scenario where the ultimate goal is to immediately paste the contents of the copied buffer.

The easiest way to do this is to split the screen into two regions. You can do this by pressing CTRL + a , then | 'This is not i. This is the PIPE sign on the keyboard.

Press CTRL + a , then TAB to switch to the second area, CTRL + a , then c to create a new session in the second area.

If you want to copy from nano and paste into the terminal, open the file in nano in the left pane, press CTRL + a , then ESC , select the start point of your copy location and press SPACE , select the text, scroll to the end point and press SPACE again to mark a copy.

Now you only need to press CTRL + a , then TAB to go to the area on the right and press CTRL + a , then ] .

The text will be written on the command line. Please note that you can also check the hardcopy parameter if you want to write directly to the file.

+1
May 08 '17 at 10:27
source share

If you just have a little information that you want to copy, simply select it with the mouse and then paste it where you want.

If you are trying to get a lot of information, a screen session can be registered in a file, and then you can copy it from a file or clear it a bit and use it to get instructions on how to perform actions

0
Apr 19 '13 at 19:46
source share

Finally, today I found a solution with the mouse:

Hold down the Ctrl key and right-click with the mouse. Copy / paste the context menu.

Some screens at https://michalzuber.wordpress.com/2015/01/28/gnu-screen-copy-paste-with-mouse/

-one
Jan 28 '15 at 9:08
source share



All Articles