I can't get this to work. How can I search the buffer of a tmux shell?
copy mode search
To search in the
tmux history buffer for the current window, press Ctrl-b [ to enter
If you're using emacs key bindings (the default), press Ctrl-s then type the string to search for and press Enter.
Press n to search for the same string again.
Press Shift-n for reverse search.
Press Escape twice to exit
You can use Ctrl-r to search in the reverse direction.
Note that since
tmux is in control of the keyboard in
copy mode, Ctrl-s works regardless of the
stty ixon setting (which I like to have as
stty -ixon to enable forward searches in Bash).
If you're using vi key bindings (Ctrl-b
:set-window-option -g mode-keys vi), press / then type the string to search for and press Enter. Press n to search for the same string again. Press Shift-n for reverse search as in emacs mode. Press q twice to exit
copy mode. You can use ? to search in the reverse direction.
If you want to switch to a window based on something displayed in it (this also includes window names and titles but not history), (starting with more than one window open) press Ctrl-b f then type the string to search for and press Enter. You will be switched to a window containing that text if it's found. If more than one window matches, you'll see a list to select from.
Enter copy mode and start searching in one go
bind-key / copy-mode \; send-key ?
allows you to do just:
Ctrl + B /
and start typing the search term.
Dump to a file and use vim
When things get more involved, I just want to use a proper editor: https://unix.stackexchange.com/questions/26548/write-all-tmux-scrollback-to-a-file
bind-key P 'capture-pane' \; capture-pane -S - \; save-buffer /tmp/tmux \; delete-buffer
P dumps the buffer to a file, and then I just:
Tested in tmux 2.6.