From 8464dad60099c59863d8fde9f9577478be000a7c Mon Sep 17 00:00:00 2001 From: Gabriel Holodak Date: Mon, 28 May 2018 14:58:32 -0400 Subject: [PATCH] Add option to disable mouse bindings --- scripts/helpers.sh | 7 +++++++ yank.tmux | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/scripts/helpers.sh b/scripts/helpers.sh index e75dcaa..905a872 100644 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -24,6 +24,9 @@ yank_selection_mouse_default="primary" yank_selection_mouse_option="@yank_selection_mouse" +yank_with_mouse_default="on" +yank_with_mouse_option="@yank_with_mouse" + yank_action_default="copy-pipe-and-cancel" yank_action_option="@yank_action" @@ -81,6 +84,10 @@ get_tmux_option "$yank_selection_mouse_option" "$yank_selection_mouse_default" } +yank_with_mouse() { + get_tmux_option "$yank_with_mouse_option" "$yank_with_mouse_default" +} + yank_action() { get_tmux_option "$yank_action_option" "$yank_action_default" } diff --git a/yank.tmux b/yank.tmux index fced78e..1902177 100755 --- a/yank.tmux +++ b/yank.tmux @@ -47,25 +47,33 @@ tmux bind-key -T copy-mode-vi "$(put_key)" send-keys -X copy-pipe-and-cancel "tmux paste-buffer" tmux bind-key -T copy-mode-vi "$(yank_put_key)" send-keys -X copy-pipe-and-cancel "$copy_command; tmux paste-buffer" tmux bind-key -T copy-mode-vi "$(yank_wo_newline_key)" send-keys -X "$(yank_action)" "$copy_wo_newline_command" - tmux bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X "$(yank_action)" "$copy_command_mouse" + if [[ "$(yank_with_mouse)" == "on" ]]; then + tmux bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X "$(yank_action)" "$copy_command_mouse" + fi tmux bind-key -T copy-mode "$(yank_key)" send-keys -X "$(yank_action)" "$copy_command" tmux bind-key -T copy-mode "$(put_key)" send-keys -X copy-pipe-and-cancel "tmux paste-buffer" tmux bind-key -T copy-mode "$(yank_put_key)" send-keys -X copy-pipe-and-cancel "$copy_command; tmux paste-buffer" tmux bind-key -T copy-mode "$(yank_wo_newline_key)" send-keys -X "$(yank_action)" "$copy_wo_newline_command" - tmux bind-key -T copy-mode MouseDragEnd1Pane send-keys -X "$(yank_action)" "$copy_command_mouse" + if [[ "$(yank_with_mouse)" == "on" ]]; then + tmux bind-key -T copy-mode MouseDragEnd1Pane send-keys -X "$(yank_action)" "$copy_command_mouse" + fi else tmux bind-key -t vi-copy "$(yank_key)" copy-pipe "$copy_command" tmux bind-key -t vi-copy "$(put_key)" copy-pipe "tmux paste-buffer" tmux bind-key -t vi-copy "$(yank_put_key)" copy-pipe "$copy_command; tmux paste-buffer" tmux bind-key -t vi-copy "$(yank_wo_newline_key)" copy-pipe "$copy_wo_newline_command" - tmux bind-key -t vi-copy MouseDragEnd1Pane copy-pipe "$copy_command_mouse" + if [[ "$(yank_with_mouse)" == "on" ]]; then + tmux bind-key -t vi-copy MouseDragEnd1Pane copy-pipe "$copy_command_mouse" + fi tmux bind-key -t emacs-copy "$(yank_key)" copy-pipe "$copy_command" tmux bind-key -t emacs-copy "$(put_key)" copy-pipe "tmux paste-buffer" tmux bind-key -t emacs-copy "$(yank_put_key)" copy-pipe "$copy_command; tmux paste-buffer" tmux bind-key -t emacs-copy "$(yank_wo_newline_key)" copy-pipe "$copy_wo_newline_command" - tmux bind-key -t emacs-copy MouseDragEnd1Pane copy-pipe "$copy_command_mouse" + if [[ "$(yank_with_mouse)" == "on" ]]; then + tmux bind-key -t emacs-copy MouseDragEnd1Pane copy-pipe "$copy_command_mouse" + fi fi }