tmux: Mimic copy-mode -e when using the wheel
`copy-mode -e` annoyed me, as it happened sometimes that I would hold down `C-d` to scroll down, only to close the shell and pane when reaching the bottom. But in principal I do like the idea of it and missed the feature when reaching the bottom by using the scroll wheel. Change the `WheelDownPane` in copy-mode to exit when the bottom is reached.
This commit is contained in:
@@ -11,15 +11,16 @@ bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-no-clear "xclip -se p"
|
||||
# https://github.com/neovim/neovim/wiki/FAQ#cursor-shape-doesnt-change-in-tmux
|
||||
set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q'
|
||||
|
||||
# Do not exit automatically the copy-mode when reaching the bottom. This was
|
||||
# especially annoying/dangerous when holding C-d down to scroll to the bottom.
|
||||
# (This is practically the default binding except for the `-e` flag for
|
||||
# `copy-mode`)
|
||||
# Scroll up one page when entering copy-mode through the mouse wheel. Also
|
||||
# discard the `-e` flag passed to copy-mode from the default binding (See below)
|
||||
bind -n WheelUpPane \
|
||||
if -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" { send -M } { copy-mode -u }
|
||||
# Scroll without selecting the pane
|
||||
bind -T copy-mode-vi WheelUpPane send -XN5 scroll-up
|
||||
bind -T copy-mode-vi WheelDownPane send -XN5 scroll-down
|
||||
bind -T copy-mode-vi WheelUpPane send -XN5 scroll-up
|
||||
# Exit copy-mode when at the bottom. This practically mimics `copy-mode -e` but
|
||||
# only scrolling with the wheel (`-e` annoys me when scrolling down with `C-d`).
|
||||
bind -T copy-mode-vi WheelDownPane \
|
||||
if -F "#{==:0,#{scroll_position}}" {send -X cancel} {send -XN5 scroll-down}
|
||||
|
||||
# Set C-a as new prefix
|
||||
unbind C-b
|
||||
|
||||
Reference in New Issue
Block a user