Terminal *output* history

bashbyobuhistory

I make extensive use of the functions to navigate through the command history in my terminal; I wonder if there is some way to navigate the command output history as well? (besides keeping a large histsize and leaning on the pgup key)

I cannot just 'rerun the command', as in my particular situation the source of the commands changes; I frequently need to look back at the output of a previous change.

Hacks welcome.

Thanks!

Edit 2010:

I've given 'tee' the credit; among all the methods to log your session elsewhere, it's the most broadly applicable (i.e. it's part of gnu coreutils, and doesnt require a specific shell or utility to work). It wasn't really what I was looking for, but I realize that such a thing doesn't really exist.

The closest approximation I can think of is to use something like screen (byobu/tmux) that logs to file, and write (and keybind) a custom command to page/search through that logfile (think less paging by prompt rather than screen). Thanks everyone.

Edit 2012:

@Dustin Kirkland's answer is clearly best, at least generally; the terminal's scrollback buffer is least-intrusive way to navigate command output history. Byobu appears to have a large default number of history lines saved (10K; tmux has 2K, GNU screen 100), and it allows regex searches (a cursory look indicates that GNU screen has no scrollback search, and tmux has only plaintext search).

Best Answer

You mention using byobu...

That's certainly one way of doing it. Byobu stores 10K lines of scrollback history per window or per split (pane).

You can enter scrollback easily by pressing Alt-PageUp, Alt-PageDown, or F7. Once you're in scrollback mode, you can search forward and backward using vi-like commands. Use /regex to search forward, and ?regex to search backward.