Skip to content

Commit 82dd031

Browse files
committed
Use correct copy-mode prefix when in emacs mode
1 parent 7bf15ee commit 82dd031

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

scripts/copycat_mode_bindings.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ extend_key() {
2424
if tmux_is_at_least 2.4; then
2525
# We fetch the current behavior of the 'key' mapping in
2626
# variable 'cmd'
27-
cmd=$(tmux list-keys -T copy-mode-$(tmux_copy_mode) | $AWK_CMD '$4 == "'$key'"' | $AWK_CMD '{ $1=""; $2=""; $3=""; $4=""; sub(" ", " "); print }')
27+
cmd=$(tmux list-keys -T $(tmux_copy_mode_string) | $AWK_CMD '$4 == "'$key'"' | $AWK_CMD '{ $1=""; $2=""; $3=""; $4=""; sub(" ", " "); print }')
2828
# If 'cmd' is already a copycat command, we do nothing
2929
if echo "$cmd" | grep -q copycat; then
3030
return
3131
fi
3232
# We save the previous mapping to a file in order to be able to recover
3333
# the previous mapping when we unbind
34-
tmux list-keys -T copy-mode-$(tmux_copy_mode) | $AWK_CMD '$4 == "'$key'"' >> /tmp/copycat_$(whoami)_recover_keys
35-
tmux bind-key -T copy-mode-$(tmux_copy_mode) "$key" run-shell "tmux $cmd; $script; true"
34+
tmux list-keys -T $(tmux_copy_mode_string) | $AWK_CMD '$4 == "'$key'"' >> /tmp/copycat_$(whoami)_recover_keys
35+
tmux bind-key -T $(tmux_copy_mode_string) "$key" run-shell "tmux $cmd; $script; true"
3636
else
3737
tmux bind-key -n "$key" run-shell "tmux send-keys '$key'; $script; true"
3838
fi

scripts/helpers.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ tmux_copy_mode() {
4141
tmux show-option -gwv mode-keys
4242
}
4343

44+
tmux_copy_mode_string() {
45+
if [ $(tmux_copy_mode) == 'vi' ]; then
46+
echo copy-mode-vi
47+
else
48+
echo copy-mode
49+
fi
50+
}
51+
4452
# === copycat mode specific helpers ===
4553

4654
set_copycat_mode() {
@@ -152,7 +160,7 @@ copycat_prev_key() {
152160
copycat_quit_copy_mode_keys() {
153161
if tmux_is_at_least 2.4; then
154162
local commands_that_quit_copy_mode="cancel"
155-
local copy_mode="copy-mode-$(tmux_copy_mode)"
163+
local copy_mode="$(tmux_copy_mode_string)"
156164
tmux list-keys -T "$copy_mode" |
157165
\grep "$commands_that_quit_copy_mode" |
158166
$AWK_CMD '{ print $4 }' |

0 commit comments

Comments
 (0)