screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells. That is, multiple console applications can be run from the same terminal, each one with its own window. But we have already talked about the screen command before. In this post we are going to focus on the scrollback buffer feature.
There is a scrollback history buffer for each virtual terminal, allowing to browse, or even to search, through the history of your windows. There is a copy-and-paste mechanism as well that allows moving text regions between windows.
By default, the buffer has only the last 100 lines of text. It can be modified running screen with the -h option:
$ screen -h 2000
It can be set in the .screenrc file too, by adding the following line:
defscrollback 5000
Finally, if you want to change the number of lines of scrollback for a single window, type
scrollback num
where num is the number of scrollback lines.
To check the number of scrollback lines in your window type C-a i to display that window's information. A line with information will be shown:
(11,1)/(80,49)+2000 +flow UTF-8 0(bash)
In this case, my scrollback is 2000 lines.
To enter scrollback/copy mode type C-a [
A status line will indicate that you have entered copy mode. Navigating in scrollback mode will be pretty familiar to vi users:
Movement keys:
- h, j, k, l move the cursor line by line or column by column.
- 0, ^ and $ move to the leftmost column, to the first or last non-whitespace character on the line.
- H, M and L move the cursor to the leftmost column of the top, center or bottom line of the window.
- + and - positions one line up and down.
- G moves to the specified absolute line (default: end of buffer).
- | moves to the specified absolute column.
- w, b, e move the cursor word by word.
- B, E move the cursor WORD by WORD (as in vi).
- C-u and C-d scroll the display up/down by the specified amount of lines while preserving the cursor position. (Default: half screen-full).
- C-b and C-f scroll the display up/down a full screen.
- g moves to the beginning of the buffer.
- % jumps to the specified percentage of the buffer.
Screen allows you to search the scrollback buffer using the following commands.
Searching:
/Vi-like search forward?Vi-like search backwardC-a sEmacs style incremental search forwardC-rEmacs style reverse i-search
In scrollback mode (or copy mode, it is the same) you can copy and paste text. The copy range is specified by setting two marks. The text between these marks will be highlighted.
Marking:
spaceto set the first or second mark respectively.Yandyused to mark one whole line or to mark from start of line.Wmarks exactly one word.
Once the text is marked, move to the window where the text is going to be copied and type C-a ]
To exit scrollback mode, hit the esc (escape) button.
For more info, man screen as always :)
Add your comment below, or trackback from your own site.
Subscribe to these comments.
Be nice. Keep it clean. Stay on topic. No spam.
You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>