SSH Terminal – How to Scroll Inside Screen or Pause Output

gnu-screenputtyscrollingsshterminal

I use screen for my command-line tasks while managing the servers where I work. I usually run small commands (mostly file-system tasks) but sometimes I run more extensive tasks (like DBA).

The output of those tasks is important to me. Since I use Ubuntu and OS X (both Terminal Windows) for my tasks, yet I need to use screen, the scrolling is not available, so any long output (think a 500-row table from a select) is invisible for me. Mouse-wheel is out of the question.

When I say "scroll is invisible for me, I mean this:

top while using screen, in Mac OS X, while scrolling

I was thinking about two options:

  1. Pause (think paginate) the output of a certain command. When the output begins, it would let me read what's happening, then I press "Enter", then the output continues until there's nothing more to show.

  2. Scroll inside screen. But I don't know if this is possible.

Of course, I don't know if those options are actually possible. If they are, how can achieve them? Other alternatives will be well received.

Best Answer

Screen has its own scroll buffer, as it is a terminal multiplexer and has to deal with several buffers.

Maybe there's a better way, but I'm used to scrolling using the "copy mode" (which you can use to copy text using screen itself, although that requires the paste command too):

  • Hit your screen prefix combination (C-a / control+A by default), then hit Escape.

  • Move up/down with the arrow keys ( and ).

  • When you're done, hit q or Escape to get back to the end of the scroll buffer.

(If instead of q or Escape you hit Enter or Return and then move the cursor, you will be selecting text to copy, and hitting Enter or Return a second time will copy it. Then you can paste with C-a followed by ].)

Of course, you can always use more and less, two commonly used pagers, which may be enough for some commands.

Related Question