How to search text in tmux?

Quick Answer

To search in tmux, first enter copy mode with Ctrl+b [, then press / to search forward or ? to search backward. Type your search pattern and press Enter. Use n and N to navigate through matches.

Ctrl+b+[then/

Detailed Explanation

Searching in tmux allows you to locate specific text within your terminal buffer, including scrollback history. This is useful for finding commands, error messages, or any specific output without having to manually scroll.

Basic search steps:

  1. Press Ctrl+b [ to enter copy mode
  2. Press / to search forward or ? to search backward
  3. Type your search pattern
  4. Press Enter to start the search
  5. Press n to find the next occurrence
  6. Press N to find the previous occurrence
  7. Press q to exit copy mode

Search behavior depends on mode:

  • Emacs mode: Default mode. Navigation keys may differ.
  • Vi mode: Set with set-window-option -g mode-keys vi in ~/.tmux.conf.

Search Pattern Types

By default, tmux search is case-sensitive and uses basic pattern matching. In vi mode, some regular expression features are supported:

  • ^ - Match start of line
  • $ - Match end of line
  • . - Match any character
  • * - Match 0 or more of previous character