"tmux set -g mouse-mode on" not scrolling

Viewed 199417

To allow scrolling a tmux pane with a mouse, I put the following in my ~/.tmux.conf file:

set -g mouse-mode on

However, nothing changes. When I scroll, it still scrolls outside of tmux. Why is this?

10 Answers

Paste here in ~/.tmux.conf

set -g mouse on

and run on terminal

tmux source-file ~/.tmux.conf

You can still using the devil logic of setting options depending on your current Tmux version: see my previous answer.

But since Tmux v1.7, set-option adds "-q" to silence errors and not print out anything (see changelog). I recommend to use this feature, it's more readable and easily expandable.

Add this to your ~/.tmux.conf:

# from v2.1
set -gq mouse on
# before v2.1
set -gq mode-mouse on
set -gq mouse-resize-pane on
set -gq mouse-select-pane on
set -gq mouse-select-window on

Restar tmux or source-file your new .tmux.conf


Side note: I'm open to remove my old answer if people prefer this one

This line:

set -g mouse-mode on

in your ~/.tmux.conf file won't work.

For one thing, the proper setting is not mouse-mode, but mode-mouse.

Second, it only works on older versions of tmux (pre-version 2; you can run tmux -V to see what version you have, but you can also run man tmux to see if mode-mouse is a supported option).

And third, technically man tmux says to use the mode-mouse option with setw (set-window-option) and not with set (set-option), although I've seen it work with set (as well as setw).


These lines should work:

If your version of tmux is recent enough (that is, if tmux -V shows version 2 or newer), you can put this line in your ~/.tmux.conf file:

set-option -g mouse on

But if you use an older version of tmux, put these lines in your ~/.tmux.conf file:

set-window-option -g mode-mouse on

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

Again, if you're not absolutely sure which line(s) to put in your ~/.tmux.conf file, run man tmux and search for mouse-mode, mouse-resize-pane, mouse-select-pane, and/or mouse-select-window. If you find them, then use those options (the ones for the older version of tmux).

Putting these lines in will allow you to use the mouse scroll wheel, it will allow you click on various panes to activate them, and it will allow you to resize panes just by clicking-and-dragging on their splitter separator.

You can also copy-and-paste using your mouse. However, you may notice that copying-and-pasting with your mouse may not work like it normally does on your console. To work around this, I've noticed that holding down the SHIFT key while using your mouse's copy/paste abilities makes them work normally again. (On MacOS, fn seems to work for me better than SHIFT.) Or you can learn tmux's approach to copy-and-pasting (which I do recommend).


A note on using tmux's native ability to copy/select/paste:

Personally, I feel that the vi keys make more sense to me than the default emacs keys (for example, it feels more natural to exit selection mode with vi mode's ENTER than with emacs mode's CTRL+w or ALT+w), so I have this in my ~/.tmux.conf file:

# For vi-like keys in copy/paste/selection mode:
set-window-option -g mode-keys vi

However, I've noticed that on older versions on tmux, this line won't work, unless I've also included the line:

set-window-option -g mode-mouse on

Good to know: Occasionally, when you're using the mouse's scroll wheel, you'll discover that your pane/screen appears to be frozen or locked up (it won't respond to keyboard input), and it's not clear what to do to unlock it.

It's not locked up. You're likely in tmux's selection mode. To get out of it, try one of these:

  • Hit ENTER. (Will likely work in vi mode.)
  • Hit ALT+w. (Will likely work in emacs mode.)
  • Hit CTRL+w. (Will likely work in emacs mode.)
  • Hit META+w. (Will likely work in emacs mode.)
  • Hit Esc. (Will likely work in emacs mode.)
  • Hit q. (Will likely work in vi mode, and may work in emacs mode as well.)

Ultimately, you can try hitting:

CTRL+w     ENTER

or:

Esc     q

Chances are, that will put you back in the normal mode where your keyboard is responsive again.


Using the mouse with vim:

I've discovered that putting this line in my ~/.vimrc file:

:set mouse=a

seems to work well with tmux, better than this line:

:set mouse=r

I can't really explain the difference; if you're a vim user, try them out and see which setting works best for you.


If you need to test out these tmux options, you may find yourself editing your ~/.tmux.conf file, exiting tmux, and then restarting tmux. This can become a tedious process, so if you want some work-arounds, here are some options:

Option1: After editing (and saving) your ~/.tmux.conf file, run this command (while in tmux):

CTRL+B :source-file ~/.tmux.conf ENTER

This will immediately apply the new settings in your ~/.tmux.conf file into your current tmux session, without the need to restart tmux.

Option 2: If you're in a tmux session, you can turn on/off options temporarily just for that session by running commands like these at the Unix shell prompt:

tmux set-option -g mouse on

tmux set-window-option -g mode-keys vi

Option 3: You can also temporarily turn on/off options in a tmux session with:

CTRL+B :set-option -g mouse on ENTER

CTRL+B :set-window-option -g mode-keys vi ENTER


Good luck, and have fun using tmux !

Try this. It works on my computer.

set -g mouse on

Ctrl + B and then set mouse. -g is not needed anymore.

Related