Scroll back and search history in tmux
How to scroll back in tmux copy mode, the emacs and vi keys, how to search, how many lines tmux keeps, and what the mouse option does.
Inside tmux, the lines that scroll off the top are kept by tmux itself, in a history buffer for each pane. You read them in copy mode.
Enter and leave copy mode
tmux commands start with the prefix key, Ctrl+b by default. According to the tmux manual's default key bindings:
- Press the prefix, then
[to enter copy mode to copy text or view the history. - Page Up enters copy mode and scrolls one page up. On a keyboard with no Page Up key, use the prefix and
[. - Press the prefix, then
]to paste the most recently copied text.
The prefix is a key chord. With the on-screen keys of this app, use the utility key bar's Ctrl, then press b, then [. See Utility key bar and on-screen keyboard.
Leave copy mode with Escape in emacs style or q in vi style.
Keys in copy mode
The mode-keys option picks the style. The default is emacs, unless the VISUAL or EDITOR environment variable contains vi.
- Page up: emacs
Page Up, viCtrl+b - Page down: emacs
Page Down, viCtrl+f - Half page up: emacs
Alt+Up, viCtrl+u - Scroll up: emacs
Ctrl+Up, viCtrl+y - Top of history: emacs
Alt+<, vig - Bottom of history: emacs
Alt+>, viG - Search backward: emacs
Ctrl+r(incremental), vi? - Repeat search: emacs
n, vin - Leave copy mode: emacs
Escape, viq
In copy mode, tmux shows the position and the number of lines in the history in the top-right corner of the pane.
How many lines tmux keeps
By default tmux keeps up to 2000 lines for each window. Change it with the history-limit option, for example in ~/.tmux.conf:
set -g history-limit 10000
A larger history uses more memory.
The mouse option
set -g mouse on makes tmux capture the mouse. The manual says that with it on, mouse events can be bound as key bindings. The default is off. Use it only if you want tmux to react to the mouse. Before you rely on a mouse wheel to scroll, check that your terminal app sends it: the keys above always work.
Related
- Unix shell basics
- Mosh or SSH?
- Screen modes
- Colors wrong in tmux: get 256 colors and true color (default-terminal, RGB)
- Can't select or copy text in tmux over SSH: mouse mode, Shift and the clipboard