Skip to content

Commit 8464dad

Browse files
committed
Add option to disable mouse bindings
1 parent d3a8735 commit 8464dad

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

scripts/helpers.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ yank_selection_option="@yank_selection"
2424
yank_selection_mouse_default="primary"
2525
yank_selection_mouse_option="@yank_selection_mouse"
2626

27+
yank_with_mouse_default="on"
28+
yank_with_mouse_option="@yank_with_mouse"
29+
2730
yank_action_default="copy-pipe-and-cancel"
2831
yank_action_option="@yank_action"
2932

@@ -81,6 +84,10 @@ yank_selection_mouse() {
8184
get_tmux_option "$yank_selection_mouse_option" "$yank_selection_mouse_default"
8285
}
8386

87+
yank_with_mouse() {
88+
get_tmux_option "$yank_with_mouse_option" "$yank_with_mouse_default"
89+
}
90+
8491
yank_action() {
8592
get_tmux_option "$yank_action_option" "$yank_action_default"
8693
}

yank.tmux

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,33 @@ set_copy_mode_bindings() {
4747
tmux bind-key -T copy-mode-vi "$(put_key)" send-keys -X copy-pipe-and-cancel "tmux paste-buffer"
4848
tmux bind-key -T copy-mode-vi "$(yank_put_key)" send-keys -X copy-pipe-and-cancel "$copy_command; tmux paste-buffer"
4949
tmux bind-key -T copy-mode-vi "$(yank_wo_newline_key)" send-keys -X "$(yank_action)" "$copy_wo_newline_command"
50-
tmux bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X "$(yank_action)" "$copy_command_mouse"
50+
if [[ "$(yank_with_mouse)" == "on" ]]; then
51+
tmux bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X "$(yank_action)" "$copy_command_mouse"
52+
fi
5153

5254
tmux bind-key -T copy-mode "$(yank_key)" send-keys -X "$(yank_action)" "$copy_command"
5355
tmux bind-key -T copy-mode "$(put_key)" send-keys -X copy-pipe-and-cancel "tmux paste-buffer"
5456
tmux bind-key -T copy-mode "$(yank_put_key)" send-keys -X copy-pipe-and-cancel "$copy_command; tmux paste-buffer"
5557
tmux bind-key -T copy-mode "$(yank_wo_newline_key)" send-keys -X "$(yank_action)" "$copy_wo_newline_command"
56-
tmux bind-key -T copy-mode MouseDragEnd1Pane send-keys -X "$(yank_action)" "$copy_command_mouse"
58+
if [[ "$(yank_with_mouse)" == "on" ]]; then
59+
tmux bind-key -T copy-mode MouseDragEnd1Pane send-keys -X "$(yank_action)" "$copy_command_mouse"
60+
fi
5761
else
5862
tmux bind-key -t vi-copy "$(yank_key)" copy-pipe "$copy_command"
5963
tmux bind-key -t vi-copy "$(put_key)" copy-pipe "tmux paste-buffer"
6064
tmux bind-key -t vi-copy "$(yank_put_key)" copy-pipe "$copy_command; tmux paste-buffer"
6165
tmux bind-key -t vi-copy "$(yank_wo_newline_key)" copy-pipe "$copy_wo_newline_command"
62-
tmux bind-key -t vi-copy MouseDragEnd1Pane copy-pipe "$copy_command_mouse"
66+
if [[ "$(yank_with_mouse)" == "on" ]]; then
67+
tmux bind-key -t vi-copy MouseDragEnd1Pane copy-pipe "$copy_command_mouse"
68+
fi
6369

6470
tmux bind-key -t emacs-copy "$(yank_key)" copy-pipe "$copy_command"
6571
tmux bind-key -t emacs-copy "$(put_key)" copy-pipe "tmux paste-buffer"
6672
tmux bind-key -t emacs-copy "$(yank_put_key)" copy-pipe "$copy_command; tmux paste-buffer"
6773
tmux bind-key -t emacs-copy "$(yank_wo_newline_key)" copy-pipe "$copy_wo_newline_command"
68-
tmux bind-key -t emacs-copy MouseDragEnd1Pane copy-pipe "$copy_command_mouse"
74+
if [[ "$(yank_with_mouse)" == "on" ]]; then
75+
tmux bind-key -t emacs-copy MouseDragEnd1Pane copy-pipe "$copy_command_mouse"
76+
fi
6977
fi
7078
}
7179

0 commit comments

Comments
 (0)