Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure tmux scroll speed

Tags:

tmux

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'"
like image 826
David Winiecki Avatar asked Mar 15 '16 04:03

David Winiecki


5 Answers

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.

like image 147
domi91c Avatar answered Oct 06 '22 08:10

domi91c


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.

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
like image 43
ideasman42 Avatar answered Oct 06 '22 08:10

ideasman42


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

like image 37
Henry Thiemann Avatar answered Oct 06 '22 09:10

Henry Thiemann


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'"
like image 37
xApple Avatar answered Oct 06 '22 08:10

xApple


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.

like image 24
2 revs Avatar answered Oct 06 '22 08:10

2 revs