34

Can tmux scroll speed (using a mouse wheel or touch pad) be configured?

Tmux 2.1 sort of broke scrolling (depending on your configuration), forcing me to update my config. I did that a few weeks ago.

But now I think tmux scrolls* slower than it used to. I think I read you can configure the scroll speed but I can't find any mention of that anywhere now.

* Scrolling with a mouse wheel that is. (I'm actually using a Macbook trackpad but I think it's equivalent to a mouse wheel.)

I know you can do 10C-u (with vi key bindings) to jump up 10 pages, but I'd also like to be able to just scroll fast with the mouse.

I think this is all the relevant config I personally have currently:

# Use the mouse to select panes, select windows (click window tabs), resize
# panes, and scroll in copy mode.
# Requires tmux version >= 2.1 (older versions have different option names for mouse)
set -g mouse on

# No need to enter copy-mode to start scrolling.
# From github.com/tmux/tmux/issues/145
# Requires tmux version >= 2.1 (older versions have different solutions)
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"
2
  • More and more I'm thinking the scroll speed in tmux didn't change in 2.1. I think I'm confusing it with plain iTerm without tmux, where scrolling has variable velocity depending on how fast you swipe across the trackpad. Probably not something that can be fixed in tmux through configuration. I bet that would need to be a tmux feature request. Commented Mar 15, 2016 at 22:25
  • It does have velocity, just not as smooth and fast as without tmux, even with a nearly empty config file. (I figure if you put enough hooks in your config it would slow things down, but that doesn't seem to be my problem.) Commented Mar 15, 2016 at 22:30

6 Answers 6

18

For tmux 2.4 and above, the following works for me:

bind -Tcopy-mode WheelUpPane send -N1 -X scroll-up
bind -Tcopy-mode WheelDownPane send -N1 -X scroll-down

This sets it to scroll 1 line at a time.

From the changelog - look for Changes from 2.3 to 2.4

Sign up to request clarification or add additional context in comments.

3 Comments

Confirming this still works in tmux 2.6 (and particularly, for touch scrolling on Android, with tmux in termux).
tried changing -N1 to -N10 on tmux 2.7 and it still scrolls only 1 line at a time, which is super slow for every use case.
I had to use -Tcopy-mode-vi for mine to work because I use vi bindings in copy mode (works in tmux 3.1b)
18

I couldn't get any of the answers here working as of tmux 2.6 (last tested on 3.2), eventually figured it out so posting another answer.

This works as a stand-alone configuration file to scroll up and down by half pages:

set -g mouse on

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

bind-key -T copy-mode-vi WheelUpPane send-keys -X halfpage-up
bind-key -T copy-mode-vi WheelDownPane send-keys -X halfpage-down

Replace the last two lines with this to scroll one line at a time:

bind-key -T copy-mode-vi WheelUpPane send-keys -X scroll-up
bind-key -T copy-mode-vi WheelDownPane send-keys -X scroll-down

2 Comments

Works great in 2.9! If you only want to scroll 1 line just replace halfpage-up/down with scroll-up/down
This should be the accepted answer, works like a charm.
17

Using the tmux-scroll-copy-mode plugin should help here.

Once you've installed it, just add set -g @scroll-speed-num-lines-per-scroll 5 to your .tmux.conf.

scroll-speed-num-lines-per-scroll - Sets the number of lines to scroll per mouse wheel scroll event. The default option is 3, which was the scroll speed in tmux 2.0. Larger numbers scroll faster. To slow down scrolling slower than one line per wheel click, set the value to a decimal between 0.0 and 1.0. With a decimal value, only that fraction of wheel events will take effect. The value should be >= 0. Examples:

"3" (default) - Scroll three lines per every mouse wheel click. "1" - One line per mouse wheel scroll click (smoothest). "0.5" - Scroll one line only on every other mouse wheel scroll click. "0.25" - Scroll one line only on every fourth mouse wheel scroll click.

1 Comment

Setting @scroll-speed-num-lines-per-scroll to 1 (smoothest) worked in tmux 2.7
7

I agree, the scrolling speed with only one line at the line is much too slow. You can make it jump half-pages:

bind -t emacs-copy WheelUpPane   halfpage-up
bind -t emacs-copy WheelDownPane halfpage-down

Still the half-page fix proposed here is much too fast and destroyes the impression of scrolling by replacing it with only the sensation of jumping. To make the scroll go at a custom speed you can add several send-keys commands like this:

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

2 Comments

Whenever working for answer kindly mention the version of tmux that your solution worked for. Or a link to the documentation.
I used tmux version 2.1. The documentation is available online.
2

Well here's a fairly bad solution (using vim navigation mode, note the k and j).

bind-key -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if-shell -Ft= '#{pane_in_mode}' 'send-keys 5 k' 'copy-mode -e'"

bind-key -n WheelDownPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if-shell -Ft= '#{pane_in_mode}' 'send-keys 5 j'"

Not sure yet what all the tradeoffs are, but for starters it is bad because 1, the cursor moves all over the place and 2, there is a lag when you switch directions, from scrolling up to scrolling down or vice versa, while the cursor moves to the other edge of the pane.

It does have the advantage though of a configurable velocity. Just change the 5's to adjust speed.

Full disclosure: I think that must have been heavily inspired by something I read somewhere else, because it's not very familiar now. I wish I would have credited my sources.

2 Comments

No ! that was a good idea :) Just need to replace k with C-y and j with C-e built-in vim scroll. No need for plugin. thanks.
Almost perfect! Slight modification to make the scroll events go to the pane which the mouse is on even when it isn't the active pane: bind-key -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if-shell -F -t = '#{pane_in_mode}' 'send-keys -t = H 5 k' 'copy-mode -e'" bind-key -n WheelDownPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if-shell -F -t = '#{pane_in_mode}' 'send-keys -t = L 5 j'" Also made it so the cursor jumps to the top/bottom when scrolling to fix the lag issue.
-1

There's a mod for tmux allowing to specify any number of commands for 'mode' keybindings: http://ershov.github.io/tmux/

You could scroll-up or scroll-down several times or do it in a loop or even create a procedure to be executed.

For example:

bind -t emacs-copy WheelUpPane tcl { scroll-up ; scroll-up }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.