Make tmux cycle back while changing panes

This commit is contained in:
Şahin Akkaya 2022-04-06 22:12:21 +03:00
parent a7ee6272ae
commit 8fbacc2fcf

View File

@ -8,13 +8,13 @@ unbind C-b
# See: https://github.com/christoomey/vim-tmux-navigator # See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" { send-keys C-h } { if -F '#{pane_at_left}' { } { select-pane -L } bind-key -n 'C-h' if-shell "$is_vim" { send-keys C-h } { if -F '#{pane_at_left}' { select-pane -L } { select-pane -L }
} }
bind-key -n 'C-j' if-shell "$is_vim" { send-keys C-j } { if -F '#{pane_at_bottom}' { } { select-pane -D } bind-key -n 'C-j' if-shell "$is_vim" { send-keys C-j } { if -F '#{pane_at_bottom}' { select-pane -D } { select-pane -D }
} }
bind-key -n 'C-k' if-shell "$is_vim" { send-keys C-k } { if -F '#{pane_at_top}' { } { select-pane -U } bind-key -n 'C-k' if-shell "$is_vim" { send-keys C-k } { if -F '#{pane_at_top}' { select-pane -U } { select-pane -U }
} }
bind-key -n 'C-l' if-shell "$is_vim" { send-keys C-l } { if -F '#{pane_at_right}' { } { select-pane -R } } bind-key -n 'C-l' if-shell "$is_vim" { send-keys C-l } { if -F '#{pane_at_right}' { select-pane -R } { select-pane -R } }
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"