3

If you are on a remote machine in a screen session you can Enter the "copy-mode" by
Ctrl+a+ESC and then use Space and the arrow keys to do a normal selection.

Now you can use a small c to set the left margin, and capital C to set the right margin then press Space again to copy the selection into the screen buffer (as described in the screen manual)

How can you get the selected block into your primary selection or clipboard on your local machine to use it in another GUI application on your desktop?

1

You can use xsel to get the buffer into your displays clipboard as described here on stackoverflow:

The steps on Linux with xsel are as follows:

  1. Copy text from your screen session into GNU screen's copy buffer.
  2. Run this command within screen: cat | xsel -b
  3. If xsel didn't report any error, now dump screen's copy buffer to STDIN: Ctrl+a+]
  4. Send an EOF to cat to terminate it: Ctrl+d

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

1

I have a special keybinding to copy screen selection to X selection using xsel:

bind b eval writebuf 'exec /bin/sh -c " xsel -i < /tmp/screen-exchange"' 'exec /bin/sh -c "killall xsel"'

I copied from somewhere but I don't remember from where now.

  • How do you use that binding? where and when do you have to type what? – rubo77 Jan 14 '15 at 13:12
  • Inside screen, after selecting area using Ctrl+a ] press Space and Ctrl+a b – Arkadiusz Drabczyk Jan 14 '15 at 13:16
0

I recommend to select rectangular block interactively.

Hold Ctrl + click left mouse button at upper left corner of copied block and then (still holding) move cursor to lower right corner. Your rectangular block should be copied. You can paste it with middle mouse button wherever you like.

  • Thanks! that is really cool, thanks for this nice hint. But in fact this is a hint for using the shell in general and unfortunately it wouldn't work without using a mouse or similar – rubo77 Jan 13 '15 at 22:21
  • @rubo77 I don't think it can be implemented in pure shell as you want to copy something from the past, something what is only visually presented. Shell cannot guess for example what was the output of previous command (in particular even previous/other shell), so it has to be feature of the terminal (not shell). – jimmij Jan 13 '15 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.