Skip to content

Commit 6f9dbe6

Browse files
committed
feat(tmux): respect single pane context for navigator keybindings
Add pane count check to vim-tmux-navigator bindings to allow key passthrough when only one pane exists, preventing unnecessary interception of C-h/j/k/l in single-pane windows.
1 parent 4cbd852 commit 6f9dbe6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

dot_config/tmux/tmux.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ set -s extended-keys on
4242
vim_pattern='(\S+/)?g?\.?(view|l?n?vim?x?|fzf)(diff)?(-wrapped)?'
4343
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
4444
| grep -iqE '^[^TXZ ]+ +${vim_pattern}$'"
45-
bind -n 'C-h' if-shell "$is_vim" 'send C-h' 'select-pane -L'
46-
bind -n 'C-j' if-shell "$is_vim" 'send C-j' 'select-pane -D'
47-
bind -n 'C-k' if-shell "$is_vim" 'send C-k' 'select-pane -U'
48-
bind -n 'C-l' if-shell "$is_vim" 'send C-l' 'select-pane -R'
45+
bind -n 'C-h' if-shell "[ #{window_panes} -gt 1 ]" 'if-shell "$is_vim" "send C-h" "select-pane -L"' 'send C-h'
46+
bind -n 'C-j' if-shell "[ #{window_panes} -gt 1 ]" 'if-shell "$is_vim" "send C-j" "select-pane -D"' 'send C-j'
47+
bind -n 'C-k' if-shell "[ #{window_panes} -gt 1 ]" 'if-shell "$is_vim" "send C-k" "select-pane -U"' 'send C-k'
48+
bind -n 'C-l' if-shell "[ #{window_panes} -gt 1 ]" 'if-shell "$is_vim" "send C-l" "select-pane -R"' 'send C-l'
4949
bind -r h resize-pane -L 5
5050
bind -r j resize-pane -D 5
5151
bind -r k resize-pane -U 5

0 commit comments

Comments
 (0)