92

Need to enable scrolling into tmux panels with mouse wheel. How can I get that tips? Can I use it (if its exist of course) with mouse-select-pane on option?

mart7ini
  • 1,519
  • 2
  • 16
  • 21
  • 1
    http://superuser.com/questions/210125/scroll-shell-output-with-mouse-in-tmux – Ciro Santilli OurBigBook.com Mar 15 '16 at 22:23
  • 1
    It is most amusing when i use and mark up questions / answers that are closed as 'off topic'. It would have been better in this case if the 'off topic question' was made on-topic by either originator or moderator. – HankCa Nov 04 '19 at 22:29
  • This question is ***NOT ABOUT HARDWARE*** ‍♂️. It is about scrolling in `tmux`. The fact that the OP mentioned the hardware used for scrolling does not make it about hardware anymore than questions about text strings are ABOUT KEYBOARDS. – iconoclast Aug 12 '20 at 00:39
  • Doesn't say it's necessarily about hardware. Says "...hardware AND SOFTWARE...". This seems like a question about how to configure a piece of software and not via programming, so sure seems off-topic to me. – CryptoFool Sep 24 '20 at 03:07

4 Answers4

124

Origin Answer (deprecated)

Try this:

setw -g mode-mouse on

It can be used with the mouse-select-pane on and mouse-select-window on options.

Update

After tmux 2.1, mode-mouse option is no longer available. You should now use:

set -g mouse on

to capture mouse event.

ShahinSorkh
  • 599
  • 1
  • 9
  • 23
dm4
  • 1,396
  • 1
  • 9
  • 4
68

There are some changes for Tmux 2.1

  • Mouse-mode has been rewritten. There's now no longer options for:

    • mouse-resize-pane
    • mouse-select-pane
    • mouse-select-window
    • mode-mouse

    Instead there is just one option: 'mouse' which turns on mouse support entirely.

So set -g mouse on

Update:

I have to use this script to make scrolling work again: https://github.com/NHDaly/tmux-scroll-copy-mode

daniel
  • 3,105
  • 4
  • 39
  • 48
  • Wow that is fantastic! I'm new to tmux and I really liked it as it solved problems with sessions, but the windows / panes metaphors were somewhat painful (eg. `Ctrl-b o` to switch panes was a pain all the time). Along with the newly discovered https://github.com/tmux-plugins/tmux-continuum things are really starting to look rosey. – HankCa Nov 03 '19 at 23:12
15

From https://blogs.oracle.com/samf/entry/smcup_rmcup_hate

In .tmux.conf:

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

where, for instance, mouse scrolling in vim in tmux scrolls vim, NOT tmux history. Very beneficial, and VERY different from history scrolling.

dldnh
  • 8,923
  • 3
  • 40
  • 52
Anil G
  • 167
  • 1
  • 2
  • 1
    I thought smcup/rmcup had nothing to do with handling mouse scrolling. it has to do with the "alternate screen" functionality, where these folks want to *turn it off* to leave the contents of vim or less on the term so that they can still see it as they type the next command. (my two cents here is I usually have space to open more terminals so I do this sort of thing in parallel terminals -- more often than not I'd rather see my previous commands after exiting from those programs anyway) – Steven Lu Apr 24 '13 at 17:23
  • This doesn't work for me. When I add this to .tmux.conf and source that file, it just causes gibberish characters to appear that the terminal prompt (for whatever program I am in). – ely Aug 01 '13 at 15:41
  • Yes, scrolling works. But on my Ubuntu computer in vim or less scrolling works through tmux history not vim or less as I expect. – Zygimantas Gatelis Jul 21 '14 at 06:32
  • That must be the default behavior. This emulate keyboard UP and DOWN arrows. Now tmux implement his own way of scrolling (as before with pgUP pgDOWN). This is a regression, it breaks things. – NVRM Oct 14 '19 at 04:29
  • this works for tmux 2.7 as well – Dudi Boy May 25 '23 at 10:49
10

For Mac OSX 10.9

First Install SimpleSIMBL

Then Install MouseTerm

Add this to your ~/.tmux.conf

set-option -g mouse-select-pane on
set-option -g mouse-select-window on
set-window-option -g mode-mouse on

For VIM Scrolling add this to your ~/.vimrc

set mouse=a
set ttymouse=xterm

Notes: see also: Scrolling inside Vim in Mac's Terminal

Community
  • 1
  • 1
user160917
  • 9,211
  • 4
  • 53
  • 63
  • In Linux I got `.tmux.conf:1: invalid option: mouse-select-pane .tmux.conf:1: invalid option: mouse-select-pane` and `.tmux.conf:3: invalid option: mode-mouse` when Tmux starts and then the session works without any change – Mariano Ruiz Jul 06 '20 at 14:02