54

I know how to scroll in tmux using the keyboard, but I noticed that it looks like there's a way to use the terminal scrollbar with GNU Screen. Can this be done with tmux?

2
  • 8
    You can't really use the terminal scrollbar with GNU Screen. The scrollbar won't actually access Screen's scrollback buffer, but the terminal's, which means that scrolled-off lines from different Screen sessions get mixed up.
    – ak2
    Commented Jul 14, 2011 at 11:18
  • 4
    iTerm2 has some future plans to [integrate with tmux ](code.google.com/p/iterm2/wiki/TmuxIntegration). Such integration seems likely to include using a native scroll bar to view the tmux history buffer. Commented Jul 25, 2011 at 5:16

3 Answers 3

58

This is possible in both GNU screen and in tmux and the workaround is similar: to fool the multiplexers into thinking that the terminal has no "alternate screen" mode (such as that used by pico, mutt, etc). This is accomplished by setting termcap commands for the session.

For GNU screen, put this in your .screenrc:

termcapinfo xterm*|xs|rxvt|terminal ti@:te@

and for tmux, add this to your .tmux.conf:

set -ga terminal-overrides ',xterm*:smcup@:rmcup@'

The 'xterm*' part of the command should be set to whatever your terminal-emulator is declared as. Some form of xterm is a good guess, but you can check yours on most sane *nix systems with:

echo $TERM

and this can usually be set in the preferences of your terminal program (ie: For Apple's Terminal.app, it's in Settings->Profile->Advanced (or Settings->Advanced->Emulation pre-yosemite) "Declare terminal as".

The end result is that the overflow ends up in the terminal's scrollback buffer instead of disappearing. Of course, since this is one static buffer, things will get messy as you switch between screen or tmux windows, but this is handy for quickly flicking up to see the output of an ls command or the such.

9
  • 3
    also, just saw superuser.com/questions/253414/… , which works as described as another alternative.
    – Doug J
    Commented Jul 25, 2011 at 2:55
  • 2
    Solution: gist.github.com/1297707
    – Nick
    Commented Apr 17, 2012 at 15:24
  • 1
    @Nick - Note that you're solving a different problem : adding mouse support to tmux. Might be a better solution for you, but it's different from using the native scrollback buffer. As long as your terminal emulator is properly defined the above will work on an y*nix, including OSX
    – Doug J
    Commented Apr 17, 2012 at 17:40
  • 1
    looks like that was a tcsh built-in. On bash you can use echo $TERM
    – Doug J
    Commented Aug 8, 2013 at 20:56
  • 2
    this "overflow" works but shows up some odd unicode characters upon exiting tmux: stackoverflow.com/q/31790939/2668831 Commented Aug 3, 2015 at 15:18
8

To enable scrolling, you can enable the built-in mouse mode in your ~/.tmux.conf as follow:

set -g mode-mouse on
1
  • This is the old format. The new one simpler: set -g mouse on
    – Addison
    Commented Nov 23, 2022 at 1:18
-1

My Env :

linux fedora 29 x86_64 workstation, GNU bash, version 4.4.23(1)-release (x86_64-redhat-linux-gnu), GNOME Terminal 3.30.3

TO DO :

  1. See the version of tmux.
$ tmux -V
tmux 2.9a
  1. Edit ~/.tmux.conf

set -g mouse on

  1. kill server

$ tmux kill-server

  1. Re-run tmux

Then it shows terminal scrollbar in each tmux panel.

But if you want to paste text to the panel, you should use ctrl shift v.

Or see this how-to-copy-and-paste-with-a-mouse-with-tmux

The above answers do not give step 3 and 4. I might be helpful to others.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .