git has a very nice feature for many of its commands: The output on an interactive terminal is passed to a pager by default, in such a way that it only keeps the pager open if there's more than one screenful of output, and it leaves the output on the terminal instead of clearing it when you exit. Is there some way to configure this to be the default for Bash in GNOME Terminal? That is, to send all TTY output (ideally including standard error) of every command to a pager.

The idea is that sometimes commands unexpectedly produce tons of output (especially in case of syntax or other errors), and some of that might even be lost because of the history settings of the terminal. It would be better to get half a chance to know what actually happened by seeing the output in a pager.

  • How would such a system recognise commands where this should not be done? E.g. console Vim, nano, mutt, less, top Oct 8 '12 at 11:25
  • Why not just set your terminal emulator to unlimited scrollback? Oct 8 '12 at 13:25
  • @jgoldschrafe I've done that before, and it ended up filling up RAM.
    – l0b0
    Oct 8 '12 at 13:42

I don't know if it is possible. But...

a couple of workaround are there:

  • in gnome-terminal you can see previous pages with Shift-PgUp / Shift-PgDn

  • if you use screen, you can see previous pages entering copy mode with Ctrl-a Esc, then moving around with PgUp, PgDn and other vi commands (to exit from copy mode, Esc).

  • +1 for GNU Screen. I also suggest Byobu (wrapper around Tmux/Screen) and its convenient F7-button to let it behave like a pager.
    – gertvdijk
    Dec 8 '12 at 0:19

I don't know if that's possible.

The next best thing may be piping things to less -FX. The -F flag will make less quit immediately if the entire input fits on one screen, and the -X will make it not clear the screen after you exit.


script is a round about way to doing just that. From the man page:

 script makes a typescript of everything printed on your terminal.  It is
 useful for students who need a hardcopy record of an interactive session
 as proof of an assignment, as the typescript file can be printed out
 later with lpr(1).
  • Close, but that doesn't actually provide a pager, which is much more handy than a separate text file, especially when running many terminals.
    – l0b0
    Aug 9 '12 at 7:56
  • @l0b0: Indeed this is why I said round about way... Aug 9 '12 at 9:56

Konsole can suspend output with CTRL + S, all buffer in current window are freezed and able to use PageUp or PageDown to navigate.

But you need to increase buffer if necessary:

enter image description here

  • 1
    Method A is exactly what I want to avoid - Adding a pager command manually to every command. Method B won't work if the command produces output quickly - By the time I click Ctrl-S (which works in other terminals as well, by the way) output has already been lost from the terminal buffer.
    – l0b0
    Oct 8 '12 at 13:51
  • @l0b0 you can increase the buffer length to i.e 5000 lines
    – daisy
    Oct 8 '12 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.