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 confi
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
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.
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'"
I couldn't get any of the answers here working as of tmux 2.6 (last tested on 2.9), eventually figured it out so posting another answer.
This works as a stand-alone configuration file.
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
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 }
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.