From 873021ba800a036d2164eba4892be2c786b35cb0 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Mon, 19 Aug 2024 17:18:43 +0200 Subject: [PATCH] tmux: Do not copy-and-cancel after a multi click If I select a word or line with a double or triple click, I want it to stay selected. --- .config/tmux/tmux.conf | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index f4804ad..f24bd20 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -16,6 +16,29 @@ set -g copy-command 'xclip -selection clipboard' # Copy selection into primary selection (without aborting) bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-no-clear "xclip -se p" +# Select word or line on double or triple click respectively (w/o aborting). +# (These are the defaults w/o the `run -d 0.3; send -X copy-pipe-and-cancel`) +bind -T copy-mode-vi DoubleClick1Pane select-pane -t= \; send -X select-word +bind -T copy-mode-vi TripleClick1Pane select-pane -t= \; send -X select-line +bind -n DoubleClick1Pane { + select-pane -t= + if -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" { + send -M + } { + copy-mode + send -X select-word + } +} +bind -n TripleClick1Pane { + select-pane -t= + if -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" { + send -M + } { + copy-mode + send -X select-line + } +} + # https://github.com/neovim/neovim/wiki/FAQ#cursor-shape-doesnt-change-in-tmux set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q'