7
votes

I just switched from GNU screen to tmux 2.0 and I was surprised to discover that I can no longer scroll back the terminal history using mouse wheel and Shift-PgUp/Shift-PgDn.

This is a major turn off for me. How do I do terminal scrolling with tmux?

PS. I am aware that I can do set-window-option -g mode-mouse on to use the mouse wheel to scroll through the tmux buffer - not the terminal buffer. Another side effect of this setting is that I can no longer do mouse selection the usual way - I have to press Shift with the left mouse button.

IOW: how do I tell tmux to pass all mouse events to the terminal emulator?

PPS. Ubuntu 15.10; gnome-terminal; the scroll bars are clearly visible on the right, but under screen they indicate that only a small part of the buffer is shown, while under tmux they indicate that there is nothing to scroll.

1
What is your terminal emulator? I suspect the issue is that due to the existence of a scrolling region (itself due to tmux's always-on status bar), or perhaps due to smcup/rmcup, your terminal emulator isn't putting scrolled-off lines in the history at all, rather than tmux taking over the mouse (it can't possibly be taking over shift-pgup/pgdn if they worked before). For example, I can scroll fine but it only shows stuff from before I attached tmux. - Random832
@Random832: see PPS. screen also has an always-on status, but it allows scrolling. - sds
I don't use screen so can't comment on what it does differently, but I tested disabling smcup/rmcup on my machine and it seems to fix it. - Random832

1 Answers

2
votes

I suspect your issue is actually that lines aren't being placed in the scrollback buffer at all, rather than tmux taking over the mouse and keys.

Tmux by default uses the "alternate screen buffer" (you may notice that if you have text on the screen, then attach and detach tmux, the text will come back). Many terminal emulators will not place text that is scrolled or erased in this mode in the scrollback buffer. To disable this, do this:

set -g terminal-overrides 'xterm*:smcup@:rmcup@'

Where xterm* is whatever your terminal reports itself as in the $TERM environment variable. You may need to detach, reset the terminal, and reattach, to have it work if you set the option interactively.

NOTE: If you use termcap instead of terminfo, use ti and te instead of smcup/rmcup.