Skip to content

Commit 2fd76aa

Browse files
authored
Fix vim-tmux-navigator version checks
When run as TPM plugin, update version check pattern to match more esoteric tmux versions (christoomey#276)
1 parent 44ba6fb commit 2fd76aa

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

‎vim-tmux-navigator.tmux‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
#!/usr/bin/env bash
22

3+
version_pat='s/^tmux[^0-9]*([.0-9]+).*/\1/p'
4+
35
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
46
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
5-
tmux bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
6-
tmux bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
7-
tmux bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
8-
tmux bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
9-
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
10-
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
11-
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
12-
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
13-
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
7+
tmux bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
8+
tmux bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
9+
tmux bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
10+
tmux bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
11+
tmux_version="$(tmux -V | sed -En "$version_pat")"
12+
tmux setenv -g tmux_version "$tmux_version"
13+
14+
#echo "{'version' : '${tmux_version}', 'sed_pat' : '${version_pat}' }" > ~/.tmux_version.json
15+
16+
tmux if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
17+
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
18+
tmux if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
19+
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
1420

1521
tmux bind-key -T copy-mode-vi C-h select-pane -L
1622
tmux bind-key -T copy-mode-vi C-j select-pane -D

0 commit comments

Comments
 (0)