diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index 5e2bccb..4d15d4b 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -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 -[hjkl] # NOTE: C-[hjkl] (w/o prefix) moves through vim splits and tmux panes # See vim-tmux-navigator