|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
| 3 | +version_pat='s/^tmux[^0-9]*([.0-9]+).*/\1/p' |
| 4 | + |
3 | 5 | is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ |
4 | 6 | | 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'" |
14 | 20 |
|
15 | 21 | tmux bind-key -T copy-mode-vi C-h select-pane -L |
16 | 22 | tmux bind-key -T copy-mode-vi C-j select-pane -D |
|
0 commit comments