Scroll shell output with mouse in tmux

shelltmux

Mouse scrolling doesn't work in tmux the way it works when I run shell without tmux (in Gnome Terminal). It seems tmux sends mouse scroll events as if I pressed Up/Down keys. But I want it to scroll though the shell output history. Is there a way to make tmux work like this?

Note: I know how to scroll with the keyboard (thanks to another question here).

I tried mouse scrolling in two versions of tmux:

Best Answer

To scroll within history of the output You would use ^b + [ You can then use M+V to page up and ^V to page down. I don't know if You can use the real PgUp and PgDown though. My terminal does not send these keys to the tmux. Instead it scrolls itself and not the tmux history.

To exit the copy mode, press ESC

To use your mouse in this mode (called copy mode) press ^b + : and enter following:

setw -g mouse on

Note: In tmux < 2.1, the option was named mode-mouse, and not mouse

Now when You change to the copy mode you can use your mouse to scroll through it. You can put this command in your ~/.tmux.conf if You want so it loads every time You run tmux.

Update: As of tmux 1.5 this option makes using the scroll wheel automatically switch to copy mode and scroll back the tmux scrollback buffer. It is not necessary to first hit Ctrl-B + [ any more. Scrolling back down to the prompt also ends copy mode automatically.

Related Question