dcsimg

Cut and Paste With Screen

By Juliet Kemp (Send Email)
Posted Sep 8, 2009


If you're running an X session, cut-and-paste is easy: Just use the mouse. But what about when you're running in a non-graphical console? Or if you just prefer to keep your fingers on the keyboard? The utility screen, which enables you to run multiple screens on the same console (along with many other useful tricks), allows non-graphical cut-and-paste.

Tip of the Trade: Mouse-clicks may be synonymous with cut-and-paste, but in a non-graphical environment, they won't help you. Enter Screen, which among its many useful tricks, enables non-graphical cut-and-paste.

To enter copy mode in screen, hit Ctrl+A, then [. You can now use the arrow keys, or vim-like keybindings, to move around the screen. 0 gets you to the start of a line, and $ to the end of a line.

  1. When you've reached the point where you want to start the copy, hit Enter.
  2. Move the cursor to the end point of your selection (you'll see what you're copying highlighted), and then hit Enter again.
  3. Now move the cursor to wherever you want to paste the selection (you can move to another screen within your session), and hit Ctrl+A ] to paste the selection.

You can also use Ctrl+A > filename to paste the selection to a filename and Ctrl+A < filename to read a file into the selection buffer so you can then paste it out again using Ctrl+A ].

When in copy mode, you can also use screen's scrollback feature (i.e., you can scroll back upward past the top of the currently displayed text) and the search function.

Use ? to search backward. This is probably what you want initially, as you'll be starting by default from the bottom of the scrollback.

/ searches forward.

Bear in mind that the default scrollback is only 100 lines. To increase this, add a line to your ~/.screenrc:

defscrollback 1000

This increases the scrollback to 1,000 lines; you can edit this value as you prefer.

Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of "Linux System Administration Recipes: A Problem-Solution Approach" (Apress, 2009).

Follow ServerWatch on Twitter

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.