Skip to content

Commit d595cc1

Browse files
committed
support tmux 2.4
TMUX has changed the way bind-keys works in version 2.4+ This change supports both older and newer versions.
1 parent 7d9c728 commit d595cc1

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

open.tmux

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,13 @@ set_copy_mode_open_bindings() {
8888
local key_bindings=$(get_tmux_option "$open_option" "$default_open_key")
8989
local key
9090
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
9398
done
9499
}
95100

@@ -98,8 +103,13 @@ set_copy_mode_open_editor_bindings() {
98103
local key_bindings=$(get_tmux_option "$open_editor_option" "$default_open_editor_key")
99104
local key
100105
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
103113
done
104114
}
105115

0 commit comments

Comments
 (0)