tmux: Manually "backport" scroll-middle if missing

First working draft
This commit is contained in:
2024-09-18 15:46:08 +02:00
parent fceea7bc32
commit c273c3ac52

View File

@@ -227,6 +227,24 @@ bind -T copy-mode-vi C-y {
}
}
# Scroll so that the current line becomes the middle one (vim's zz)
if -F "#{<:#{version},3.4}" {
# Simulate when scroll-middle does not exist yet
# TODO: do the scroll_position and cursor_y calculations only once here
bind -T copy-mode-vi z {
set -F @middle_line "#{e|/:#{e|-:#{pane_height},1},2}"
set -F @scroll_to_middle "#{e|-:#{copy_cursor_y},#{@middle_line}}"
if -F "#{e|<:#{@scroll_to_middle},0}" {
run "tmux send -N #{e|*:-1,#{@scroll_to_middle}} C-y"
} { if -F "#{e|>:#{@scroll_to_middle},0}" {
run "tmux send -N #{@scroll_to_middle} C-e"
} }
}
} {
# should be the default, but here for verboseness
bind -T copy-mode-vi z send -X scroll-middle
}
# Navigate panes with <prefix>-[hjkl]
# NOTE: C-[hjkl] (w/o prefix) moves through vim splits and tmux panes
# See vim-tmux-navigator