Scroll inside Screen, or Pause Output

  • 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.

  • njsg

    njsg Correct answer

    8 years ago

    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.

    Also, pressing q quits copy mode without copying anything (and it's one less button press). This might be in the vi explanation but the link is now broken.

    Also pressing [Esc] exits from copy mode too.

    any way to page-up?

    Scroll buffer seems to support vi-like commands: C-b and C-f for scrolling page up/down.

    In copy mode my PageUp and PageDown buttons work. First press only moves one line but after that it pages like normal.

    There is no such thing as the "Return" key on Windows.

    `q` also exits copy mode.

    I finally had some time to sit down and rewrite this answer taking into account some of the comments. @NathanaelFarley three years is probably a long time, but `q` is now there (Cc: @Walf). @Sopalajo as is `Esc` two years later.

    @dtbarne Key naming is possibly a bit more complex than that — Enter and Return should be two different keys. As this also works with the key known as "Enter", I put both names there.

    Did the default prefix combo change? On Ubuntu 16.04, `C-A`/`C-a` didn't do anything for me...

    This is a global KDE shortcut. It can be disabled in `System Settings | Shortcuts | Global Shortcuts | KDE Deamon`

    Note to myself: ctrl+a - esc to enter copy mode, ctrl+b/ctrl+f to move up/down 1 page, ctrl+u/ctrl+d to move up/down half page. Ref:

    @polynomial_donut I thought it was not working for me as well on my Debian 10 server but it was because I read too fast and was confusing the word "escape" with "space" (which in my native language French is written "espace", very close to "escape" in English, just 2 letters are swapped) :D

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM