File tree Expand file tree Collapse file tree 2 files changed +42
-4
lines changed Expand file tree Collapse file tree 2 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -88,8 +88,13 @@ set_copy_mode_open_bindings() {
88
88
local key_bindings=$( get_tmux_option " $open_option " " $default_open_key " )
89
89
local key
90
90
for key in $key_bindings ; do
91
- tmux bind-key -t vi-copy " $key " copy-pipe " $open_command "
92
- tmux bind-key -t emacs-copy " $key " copy-pipe " $open_command "
91
+ if tmux-is-at-least 2.4; then
92
+ tmux bind-key -T copy-mode-vi " $key " send-keys -X copy-pipe-and-cancel " $open_command "
93
+ tmux bind-key -T copy-mode " $key " send-keys -X copy-pipe-and-cancel " $open_command "
94
+ else
95
+ tmux bind-key -t vi-copy " $key " copy-pipe " $open_command "
96
+ tmux bind-key -t emacs-copy " $key " copy-pipe " $open_command "
97
+ fi
93
98
done
94
99
}
95
100
@@ -98,8 +103,13 @@ set_copy_mode_open_editor_bindings() {
98
103
local key_bindings=$( get_tmux_option " $open_editor_option " " $default_open_editor_key " )
99
104
local key
100
105
for key in $key_bindings ; do
101
- tmux bind-key -t vi-copy " $key " copy-pipe " $editor_command "
102
- tmux bind-key -t emacs-copy " $key " copy-pipe " $editor_command "
106
+ if tmux-is-at-least 2.4; then
107
+ tmux bind-key -T copy-mode-vi " $key " send-keys -X copy-pipe-and-cancel " $editor_command "
108
+ tmux bind-key -T copy-mode " $key " send-keys -X copy-pipe-and-cancel " $editor_command "
109
+ else
110
+ tmux bind-key -t vi-copy " $key " copy-pipe " $editor_command "
111
+ tmux bind-key -t emacs-copy " $key " copy-pipe " $editor_command "
112
+ fi
103
113
done
104
114
}
105
115
Original file line number Diff line number Diff line change @@ -42,3 +42,31 @@ get_engine() {
42
42
local engine_var=" $1 "
43
43
tmux show-options -g | grep -i " ^@open-$engine_var " | cut -d ' ' -f2 | xargs
44
44
}
45
+
46
+ tmux_version=" $( tmux -V | cut -d ' ' -f 2) "
47
+ tmux-is-at-least () {
48
+ if [[ $tmux_version == $1 ]]
49
+ then
50
+ return 0
51
+ fi
52
+
53
+ local IFS=.
54
+ local i tver=($tmux_version ) wver=($1 )
55
+
56
+ # fill empty fields in tver with zeros
57
+ for (( i= ${# tver[@]} ; i< ${# wver[@]} ; i++ )) ; do
58
+ tver[i]=0
59
+ done
60
+
61
+ # fill empty fields in wver with zeros
62
+ for (( i= ${# wver[@]} ; i< ${# tver[@]} ; i++ )) ; do
63
+ wver[i]=0
64
+ done
65
+
66
+ for (( i= 0 ; i< ${# tver[@]} ; i++ )) ; do
67
+ if (( 10 #${tver[i]} < 10 #${wver[i]} )) ; then
68
+ return 1
69
+ fi
70
+ done
71
+ return 0
72
+ }
You can’t perform that action at this time.
0 commit comments