With tmux 1.5 (and later), you can give negative numbers to the -S
option of capture-pane
to access the scroll back buffer.
Examples:
Capture (up to) 32768 lines of the scroll back buffer along with the pane’s current text:
tmux capture-pane -pS -32768
Capture just the tenth most recently “scrolled off” line:
tmux capture-pane -pS -10 -E -10
Capture (up to) the 100 most-recently “scrolled off” lines:
tmux capture-pane -pS -100 -E -1
Capture eleven lines that straddle the current top line of the pane (5 “scrolled off” lines, and the top 6 lines of the pane):
tmux capture-pane -pS -5 -E 5
Note: As with most tmux commands, you can use -t
to target a specific pane if the “current” pane is not the one you are interested in probing.
The above examples also use the -p
option to capture-pane
, which is only available starting in tmux 1.8. With older versions you could work around not having it by using save-buffer
:
tmux capture-pane -S -32768 \; save-buffer - \; delete-buffer