10

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.

Community
  • 1
  • 1
sds
  • 58,617
  • 29
  • 161
  • 278
  • 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 Oct 28 '15 at 18:39
  • @Random832: see PPS. `screen` also has an always-on status, but it allows scrolling. – sds Oct 28 '15 at 18:44
  • 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 Oct 28 '15 at 18:46
  • I'm trying out tmux 2.6 after using screen for years. I have the same problem. None of the solutions here https://superuser.com/questions/209437/how-do-i-scroll-in-tmux or here https://superuser.com/questions/310251/use-terminal-scrollbar-with-tmux?lq=1 work. – aswine Aug 25 '21 at 19:13

1 Answers1

3

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.

Random832
  • 37,415
  • 3
  • 44
  • 63
  • 2
    I see no change in behaviour with your setting. – sds Oct 28 '15 at 18:55
  • @sds Did you try adding it to tmux.conf and then starting a new tmux instance in a new terminal, in case something didn't get reset properly? What is the value of $TERM? Did you turn `mode-mouse` back off? – Random832 Oct 28 '15 at 19:00
  • 1
    yes, this is precisely what I did; my `TERM` is `xterm-256color`. – sds Oct 28 '15 at 19:02
  • @sds How are you generating content to scroll through? I don't know how to investigate this further; this solution worked for me. – Random832 Oct 28 '15 at 19:03
  • 1
    `cat /var/log/messages` – sds Oct 28 '15 at 19:07
  • This works for me with an explicit `set -g mode-mouse off` in `.tmux.conf`. My terminal is `xfce4-terminal` (though `$TERM` says `xterm`)... – sphakka Jun 18 '16 at 14:11