Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I can't get this to work. How can I search the buffer of a tmux shell?

share|improve this question
    
What version of tmux (tmux -V)? I believe this was added in version 0.9. –  Dennis Williamson Jan 9 '11 at 20:43
    
@Dennis it's 1.3-1 –  NES Jan 9 '11 at 21:08
    
Finding the version with tmux -V works only in later versions. In Ubuntu/Debian you can do: dpkg -l | grep tmux –  Niels Bom Oct 4 '12 at 11:46

1 Answer 1

up vote 65 down vote accepted

copy mode search

To search in the tmux history buffer for the current window, press Ctrl-b [ to enter copy mode.

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 Escape twice to exit copy mode. 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, press / then type the string to search for and press Enter. Press n to search for the same string again. Press q twice to exit copy mode. You can use ? to search in the reverse direction.

find-window

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.

share|improve this answer
    
How can I set the binding style? (emacs vs vi) –  Daniel Que Aug 12 at 22:39
1  
@DanielQue: Take a look at the tmux man page and search for "mode-keys" and "status-keys". Those are sub-commands that allow you to set the binding style. Alternately, it might be simpler to set an environment variable (EDITOR or VISUAL) to the style you want before starting tmux. –  Dennis Williamson Aug 12 at 22:55
1  
Thanks, I got it to work with set-window-option -g mode-keys vi in my .tmux.conf. But I was curious about the environment variable alternative and couldn't get it to work. Is it a shell environment variable, or a tmux environment variable that has to be set in the conf file? –  Daniel Que Aug 12 at 23:38
1  
@DanielQue: A shell environment variable. It will need to be exported or placed in tmux's envrionment like this: VISUAL=vi tmux –  Dennis Williamson Aug 13 at 4:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.