Cut and Paste With Screen
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.
- When you've reached the point where you want to start the copy, hit Enter.
- Move the cursor to the end point of your selection (you'll see what you're copying highlighted), and then hit Enter again.
- 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:
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).