Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just started using tmux, and I really like it, but I need to be able to scroll within the buffers/panes/windows I have open. I don't care if it works with the mouse or not. When I search the tmux man page, I find only two instances of the word "scroll" even showing up, and both have to do with copy mode. Is there a way to scroll without all the overhead of entering copy mode?

share|improve this question
7  
What overhead are you concerned with? copy-mode is the way to view history (and optionally copy stuff out of it). – Chris Johnsen Nov 11 '10 at 5:48
    
for me you can press f7 for scroll mode and q to quit – JohnMerlino Jul 25 '14 at 14:56
up vote 737 down vote accepted

Ctrl-b then [ then you can use your normal navigation keys to scroll around (eg. Up Arrow or PgDn). Press q to quit scroll mode.

Alternatively you can press Ctrl-b PgUp to go directly into copy mode and scroll one page up (which is what it sounds like you will want most of the time)

In vi mode (see below), you can also scroll the page up/down line by line using Shift-k and Shift-j (if you're already in scroll mode). Unshifted, the cursor moves instead of the page.

Excerpts from the man page:

tmux may be controlled from an attached client by using a key combination of a prefix key, ‘C-b’ (Ctrl-b) by default, followed by a command key.

 The default command key bindings are:

[           Enter copy mode to copy text or view the history.

Function                     vi              emacs
--------                     --              -----
Half page down               C-d             M-Down
Half page up                 C-u             M-Up
Next page                    C-f             Page down
Previous page                C-b             Page up
Scroll down                  C-Down or C-e   C-Down
Scroll up                    C-Up or C-y     C-Up
Search again                 n               n
Search again in reverse      N               N
Search backward              ?               C-r
Search forward               /               C-s

Plus a bunch more. Note that you have to press C-b twice if you use that for page up since C-b is bound as the command key. See the man page for information on prefacing a copy mode command with a repeat count.

You can set the key binding mode using Ctrl-b, then

:set-window-option mode-keys emacs

or vi.

share|improve this answer
9  
I think C-b = is choose-buffer by default. Did you mean C-b [ (which is copy-mode by default)? Also you can also use C-b PageUp to start copy-mode directly on the previous page (very handy when you know what you want to view/copy has already scrolled off the current page). – Chris Johnsen Nov 11 '10 at 5:55
4  
Correct, my tmux has no scroll-mode. You need to C-b [ to enter copy mode and then use either the emacs or vi key-bindings to scroll around. This seems like a lot of steps just to scroll, but the benefits of tmux still outweigh these annoyances. I'm on a macbook and there is no PageUp key :-\. (Also, how do I make keys with markdown like you did, Dennis?) – chadoh Nov 11 '10 at 17:11
31  
@chadoh: Try these on your Macbook: Home: fn-LeftArrow; End: fn-RightArrow; Page Up: fn-UpArrow; Page Down: fn-DownArrow. To make keycaps: <kbd>Ctrl</kbd> – Dennis Williamson Nov 11 '10 at 18:43
3  
on macbook, the fn+up goes straight to terminal app and never hits tmux – Tyler Apr 11 '11 at 17:57
13  
On a macbook if you're in scroll mode you can use fn+Shift+LeftArrow to scroll up a page. – Nick Hammond May 18 '13 at 17:51

Well, you should consider the proper way to set scrolling: add in your tmux.conf

set -g mode-mouse on

It worked for me in windows and panes. Now tmux is just perfect.

Practical tmux has more info on tmux.conf files.

share|improve this answer
3  
When I do this, mouse clicks and scrolls cause gibberish characters to be printed to the prompt area of the terminal I'm using with tmux. Any ideas? – Mr. F Aug 1 '13 at 15:38
    
This works great for me. Now if only we can figure key bindings to do the same (maybe a screen at a time), I'll be a very happy camper. – Jonathan Hartley Nov 4 '13 at 9:45
5  
Future tmux mouse users: To save you having to scroll to the bottom again before typing, you can hit q to exit scroll mode. – Jezen Thomas Jan 7 '14 at 5:11
5  
Mouse scrolling works fine with this, but unfortunately I cannot use the mouse to select text anymore. Using Tilda and tmux. – friederbluemle Mar 17 '15 at 3:40
10  
Note that in tmux 2.1 and up, this is replaced with set -g mouse on, and scrolling does not automatically enter copy mode like it did before. – thrnio Oct 29 '15 at 22:49

From my .tmux.conf:

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

This enables native xterm scrolling.

share|improve this answer
21  
Can you explain what this does exactly? – Ivo Oct 31 '11 at 6:25
7  
I don't know what it does, but it is pure genius. Finally, tmux scrolling works, yay! – oneself Nov 28 '11 at 21:26
4  
This doesn't work for me on OS X... – Nick Apr 17 '12 at 13:56
16  
Solution: gist.github.com/1297707 – Nick Apr 17 '12 at 15:25
5  
Check this out if you're confused about togdon's answer: superuser.com/questions/310251/… IMO, if you have only a single pane, this solution works better than the accepted answer. – thameera Apr 16 '13 at 7:48

This is the way I made it work, and the reasons why I think it is better than the default way.

To try it out, put all the code sections in ~/.tmux.conf.

Step 1. Change the prefix key so you won't have to reach one bit. 'B' is seemingly a close key, but it is in the middle of the two index fingers (at 'F' and 'J', respectively). Because that shortcut is essential in tmux, C-j is much better as it involves zero hand movement (apart from hitting the key).

set -g prefix C-j
unbind C-b
bind C-j send-prefix

Step 2. 'S' (to enter copy-mode) is: 1) close (same reason as above), 2) involves the other hand (compare: the 1-2 in boxing, or the ls command to view files in a directory), and 3) could be thought of as mnemonic for "scroll" (although the copy-mode isn't just about scrolling).

bind s copy-mode

Step 3. The last part, the actual scrolling. 'P' and 'N' are familiar for this purpose to the Emacs users. They are close, intuitive ('P' is above 'N' on the keyboard), and mnemonic ("previous" and "next"). If you just did some scrolling in Emacs, and then go to tmux, it makes sense to have those shortcuts.

However, I found that 'I' and 'K' are even better - they are even closer than 'P' and 'N', and intuitive (for the same reason); as for mnemonics - as scrolling is such a common thing to do, mnemonics won't really matter as the shortcuts will soon bypass your brain and enter the muscle memory.

bind -t emacs-copy 'p' scroll-up
bind -t emacs-copy 'n' scroll-down
bind -t emacs-copy 'i' scroll-up
bind -t emacs-copy 'k' scroll-down
share|improve this answer

For the newest tmux 2.1, to scroll with your mouse sanely, this is the right answer:

set -g mouse on
" sane scrolling:
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e; send-keys -M'"

it's not enough to just reload your .tmux.conf you need to restart your tmux, e.g. tmux kill-server && tmux

taken from https://github.com/tmux/tmux/issues/145

share|improve this answer

In my case, just opt + UpArrow and opt + DownArrow on OSX.

share|improve this answer
    
@fixer1234 The question does not mention Linux at all. tmux can be used on OS X, too. – slhck Apr 17 '15 at 11:51
    
@slhck: Thanks. Too bleary-eyed; astigmatism kicked in. I had misread the tmux tag as a linux tag. – fixer1234 Apr 17 '15 at 16:07

The only thing that works for me is putting the following in ~/.tmux.conf

# Allow xterm titles in terminal window, terminal scrolling with scrollbar, and setting overrides of C-Up, C-Down, C-Left, C-Right
set -g terminal-overrides "xterm*:XT:smcup@:rmcup@:kUP5=\eOA:kDN5=\eOB:kLFT5=\eOD:kRIT5=\eOC"

(you may need to reboot for this to take effect)

share|improve this answer
1  
This one actually solves my scrolling problem in iPhone app as well. – NathaneilCapital Jun 17 at 17:20

I searched around a lot for this and the best solution for me works as mentioned in this detailed guide: http://tangledhelix.com/blog/2012/07/16/tmux-and-mouse-mode/

Add these bindings in ~/.tmux.conf:

set -g mode-mouse on

unbind +
bind + \
  new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \;\
  swap-pane -s tmux-zoom.0 \;\
  select-window -t tmux-zoom

unbind -
bind - \
  last-window \;\
  swap-pane -s tmux-zoom.0 \;\
  kill-window -t tmux-zoom

With the above approach implemented, you can copy from panes in a window as well by zooming into each pane first using Prefix +.

One important detail that was missing with the mouse mode is to press Shift before selecting an area to copy. This will copy it to traditional terminal buffer instead of the tmux copy buffer. (https://wiki.archlinux.org/index.php/Tmux#Scrolling_issues)

share|improve this answer
    
Appreciate your answer. But many a times the referred links may break. It would always be beneficial to add the core part of your answer here and provide the link just for reference. – Prasanna Mar 31 at 1:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.