41
20
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?
41
20
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?
43
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.
1
this "overflow" works but shows up some odd unicode characters upon exiting tmux: http://stackoverflow.com/q/31790939/2668831
– Louis Maddox – 2015-08-03T15:18:46.410Note, I think you want to be sure mouse mode is off when using this approach. That way the terminal rather than tmux is doing the scrolling. So set -g mouse-mode off
in tmux < 2.1 and set -g mouse off
for tmux 2.1+. – studgeek – 2017-12-22T17:20:24.497
2
also, just saw http://superuser.com/questions/253414/how-to-enter-copy-mode-on-mouse-scroll-in-tmux , which works as described as another alternative.
– Doug J – 2011-07-25T02:55:03.897This doesn't work for me on OS X... – Nick – 2012-04-17T13:57:30.327
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 – 2012-04-17T17:40:33.490
That's correct. I was trying to get some sort of scrolling in tmux, specifically under OS X. Just figured I'd post it here for posterity. Also, your solution probably didn't work for me because I wasn't reloading the .tmux.conf file (or tmux kill-server) (or C-b :source ~/.tmux.conf) (or C-b :set -g terminal-ov...) =) – Nick – 2012-04-18T14:33:44.250
Is termname
a shell command? I get 'command not found' using bash on linux, I can't apt-get install termname, and I can't find any evidence it exists from googling around. – Mu Mind – 2013-08-08T16:07:34.780
1looks like that was a tcsh built-in. On bash you can use echo $TERM
– Doug J – 2013-08-08T20:56:38.353
5
To enable scrolling, you can enable the built-in mouse mode in your ~/.tmux.conf
as follow:
set -g mode-mouse on
6You 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 – 2011-07-14T11:18:39.373
@ak2 Sadness... but thanks for the info! – Jeff – 2011-07-14T22:03:35.797
2iTerm2 has some future plans to integrate with tmux . Such integration seems likely to include using a native scroll bar to view the tmux history buffer. – Chris Johnsen – 2011-07-25T05:16:36.837