Strovent SystemsSign in
Reference

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, vi Ctrl+b
  • Page down: emacs Page Down, vi Ctrl+f
  • Half page up: emacs Alt+Up, vi Ctrl+u
  • Scroll up: emacs Ctrl+Up, vi Ctrl+y
  • Top of history: emacs Alt+<, vi g
  • Bottom of history: emacs Alt+>, vi G
  • Search backward: emacs Ctrl+r (incremental), vi ?
  • Repeat search: emacs n, vi n
  • Leave copy mode: emacs Escape, vi q

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.

Sources

Spotted a mistake? Email [email protected].