1
1
#! /usr/bin/env bash
2
2
3
3
get_tmux_option () {
4
- local option=$1
5
- local default_value=$2
6
- local option_value
7
- option_value=$( tmux show-option -gqv " $option " )
8
- if [ -z " $option_value " ]; then
9
- echo " $default_value "
10
- else
11
- echo " $option_value "
12
- fi
4
+ local option=$1
5
+ local default_value=$2
6
+ local option_value
7
+ option_value=$( tmux show-option -gqv " $option " )
8
+ if [ -z " $option_value " ]; then
9
+ echo " $default_value "
10
+ else
11
+ echo " $option_value "
12
+ fi
13
13
}
14
14
15
15
is_vim=" ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\ S+\\ /)?g?\.?(view|n?vim?x?)(-wrapped)?(diff)?$'"
@@ -25,27 +25,27 @@ navigation_kb_up=$(get_tmux_option "@tmux-nvim-navigation-keybinding-up" 'C-k')
25
25
navigation_kb_right=$( get_tmux_option " @tmux-nvim-navigation-keybinding-right" ' C-l' )
26
26
27
27
if $navigation_enabled ; then
28
- if $navigation_cycle ; then
29
- tmux bind-key -n " $navigation_kb_left " if-shell " $is_vim " " send-keys $navigation_kb_left " ' select-pane -L'
30
- tmux bind-key -n " $navigation_kb_down " if-shell " $is_vim " " send-keys $navigation_kb_down " ' select-pane -D'
31
- tmux bind-key -n " $navigation_kb_up " if-shell " $is_vim " " send-keys $navigation_kb_up " ' select-pane -U'
32
- tmux bind-key -n " $navigation_kb_right " if-shell " $is_vim " " send-keys $navigation_kb_right " ' select-pane -R'
28
+ if $navigation_cycle ; then
29
+ tmux bind-key -n " $navigation_kb_left " if-shell " $is_vim " " send-keys $navigation_kb_left " ' select-pane -L'
30
+ tmux bind-key -n " $navigation_kb_down " if-shell " $is_vim " " send-keys $navigation_kb_down " ' select-pane -D'
31
+ tmux bind-key -n " $navigation_kb_up " if-shell " $is_vim " " send-keys $navigation_kb_up " ' select-pane -U'
32
+ tmux bind-key -n " $navigation_kb_right " if-shell " $is_vim " " send-keys $navigation_kb_right " ' select-pane -R'
33
33
34
- tmux bind-key -T copy-mode-vi " $navigation_kb_left " select-pane -L
35
- tmux bind-key -T copy-mode-vi " $navigation_kb_down " select-pane -D
36
- tmux bind-key -T copy-mode-vi " $navigation_kb_up " select-pane -U
37
- tmux bind-key -T copy-mode-vi " $navigation_kb_right " select-pane -R
38
- else
39
- tmux bind-key -n " $navigation_kb_left " if-shell " $is_vim " " send-keys $navigation_kb_left " " if -F '#{pane_at_left}' '' 'select-pane -L'"
40
- tmux bind-key -n " $navigation_kb_down " if-shell " $is_vim " " send-keys $navigation_kb_down " " if -F '#{pane_at_bottom}' '' 'select-pane -D'"
41
- tmux bind-key -n " $navigation_kb_up " if-shell " $is_vim " " send-keys $navigation_kb_up " " if -F '#{pane_at_top}' '' 'select-pane -U'"
42
- tmux bind-key -n " $navigation_kb_right " if-shell " $is_vim " " send-keys $navigation_kb_right " " if -F '#{pane_at_right}' '' 'select-pane -R'"
34
+ tmux bind-key -T copy-mode-vi " $navigation_kb_left " select-pane -L
35
+ tmux bind-key -T copy-mode-vi " $navigation_kb_down " select-pane -D
36
+ tmux bind-key -T copy-mode-vi " $navigation_kb_up " select-pane -U
37
+ tmux bind-key -T copy-mode-vi " $navigation_kb_right " select-pane -R
38
+ else
39
+ tmux bind-key -n " $navigation_kb_left " if-shell " $is_vim " " send-keys $navigation_kb_left " " if -F '#{pane_at_left}' '' 'select-pane -L'"
40
+ tmux bind-key -n " $navigation_kb_down " if-shell " $is_vim " " send-keys $navigation_kb_down " " if -F '#{pane_at_bottom}' '' 'select-pane -D'"
41
+ tmux bind-key -n " $navigation_kb_up " if-shell " $is_vim " " send-keys $navigation_kb_up " " if -F '#{pane_at_top}' '' 'select-pane -U'"
42
+ tmux bind-key -n " $navigation_kb_right " if-shell " $is_vim " " send-keys $navigation_kb_right " " if -F '#{pane_at_right}' '' 'select-pane -R'"
43
43
44
- tmux bind-key -T copy-mode-vi " $navigation_kb_left " " if -F '#{pane_at_left}' '' 'select-pane -L'"
45
- tmux bind-key -T copy-mode-vi " $navigation_kb_down " " if -F '#{pane_at_bottom}' '' 'select-pane -D'"
46
- tmux bind-key -T copy-mode-vi " $navigation_kb_up " " if -F '#{pane_at_top}' '' 'select-pane -U'"
47
- tmux bind-key -T copy-mode-vi " $navigation_kb_right " " if -F '#{pane_at_right}' '' 'select-pane -R'"
48
- fi
44
+ tmux bind-key -T copy-mode-vi " $navigation_kb_left " " if -F '#{pane_at_left}' '' 'select-pane -L'"
45
+ tmux bind-key -T copy-mode-vi " $navigation_kb_down " " if -F '#{pane_at_bottom}' '' 'select-pane -D'"
46
+ tmux bind-key -T copy-mode-vi " $navigation_kb_up " " if -F '#{pane_at_top}' '' 'select-pane -U'"
47
+ tmux bind-key -T copy-mode-vi " $navigation_kb_right " " if -F '#{pane_at_right}' '' 'select-pane -R'"
48
+ fi
49
49
fi
50
50
51
51
# resize
@@ -60,13 +60,13 @@ resize_kb_up=$(get_tmux_option "@tmux-nvim-resize-keybinding-up" 'M-k')
60
60
resize_kb_right=$( get_tmux_option " @tmux-nvim-resize-keybinding-right" ' M-l' )
61
61
62
62
if $resize_enabled ; then
63
- tmux bind -n " $resize_kb_left " if-shell " $is_vim " " send-keys $resize_kb_left " " resize-pane -L $resize_step_x "
64
- tmux bind -n " $resize_kb_down " if-shell " $is_vim " " send-keys $resize_kb_down " " resize-pane -D $resize_step_y "
65
- tmux bind -n " $resize_kb_up " if-shell " $is_vim " " send-keys $resize_kb_up " " resize-pane -U $resize_step_y "
66
- tmux bind -n " $resize_kb_right " if-shell " $is_vim " " send-keys $resize_kb_right " " resize-pane -R $resize_step_x "
63
+ tmux bind -n " $resize_kb_left " if-shell " $is_vim " " send-keys $resize_kb_left " " resize-pane -L $resize_step_x "
64
+ tmux bind -n " $resize_kb_down " if-shell " $is_vim " " send-keys $resize_kb_down " " resize-pane -D $resize_step_y "
65
+ tmux bind -n " $resize_kb_up " if-shell " $is_vim " " send-keys $resize_kb_up " " resize-pane -U $resize_step_y "
66
+ tmux bind -n " $resize_kb_right " if-shell " $is_vim " " send-keys $resize_kb_right " " resize-pane -R $resize_step_x "
67
67
68
- tmux bind-key -T copy-mode-vi " $resize_kb_left " resize-pane -L " $resize_step_x "
69
- tmux bind-key -T copy-mode-vi " $resize_kb_down " resize-pane -D " $resize_step_y "
70
- tmux bind-key -T copy-mode-vi " $resize_kb_up " resize-pane -U " $resize_step_y "
71
- tmux bind-key -T copy-mode-vi " $resize_kb_right " resize-pane -R " $resize_step_x "
68
+ tmux bind-key -T copy-mode-vi " $resize_kb_left " resize-pane -L " $resize_step_x "
69
+ tmux bind-key -T copy-mode-vi " $resize_kb_down " resize-pane -D " $resize_step_y "
70
+ tmux bind-key -T copy-mode-vi " $resize_kb_up " resize-pane -U " $resize_step_y "
71
+ tmux bind-key -T copy-mode-vi " $resize_kb_right " resize-pane -R " $resize_step_x "
72
72
fi
0 commit comments