From 8ab681627c05511e0b3d76825911a8b6ce050d4e Mon Sep 17 00:00:00 2001 From: bchanot Date: Tue, 6 Oct 2026 15:13:00 +0200 Subject: [PATCH 1/3] fix(tmux): a click in copy-mode returns to the prompt MouseDown1Pane in copy-mode-vi now cancels the mode instead of only clearing the selection. Drag-select (root MouseDrag1Pane re-enters copy-mode) and click-to-switch-pane are unchanged. --- tmux.conf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tmux.conf b/tmux.conf index b7020d2..5f4cce2 100644 --- a/tmux.conf +++ b/tmux.conf @@ -151,10 +151,12 @@ if-shell 'command -v pbcopy >/dev/null' \ bind-key -Tcopy-mode-vi Escape send -X cancel # cancel v mode bind-key -Tcopy-mode-vi ^v send -X rectangle-toggle # cancel v mode -bind-key -T copy-mode-vi MouseDown1Pane select-pane\; send-keys -X clear-selection +bind-key -T copy-mode-vi MouseDown1Pane select-pane -t = \; send-keys -X cancel bind -n MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= \"#{pane_in_mode}\" \"copy-mode -eM\" \"send-keys -M\"' 'copy-mode -eM' # (note) {{{ -# The `bind-key -T copy-m...` let a single click do selection clearing for us. +# The `bind-key -T copy-m...` makes a single click leave copy-mode: back to +# the prompt, selection dropped. A drag still selects (MouseDrag1Pane below +# re-enters copy-mode) and a click on another pane still switches to it. # The `bind -n MouseDrag1Pane if -Ft= ...` changes the default binding of # MouseDrag1Pane, the only difference is that we use `copy-mode -eM` instead # of `copy-mode -M`, so that WheelDownPane can trigger copy-mode to exit when From 51aed0e24d9ada1581074f57f50798c17552867e Mon Sep 17 00:00:00 2001 From: bchanot Date: Tue, 6 Oct 2026 15:17:21 +0200 Subject: [PATCH 2/3] fix(tmux): return to the prompt on click release, not on press MouseDown cancelled copy-mode before a drag could start, so selecting text after scrolling up jumped back to the bottom. MouseUp1Pane (sent only when no drag happened) now cancels; MouseDown clears the selection as before. --- tmux.conf | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tmux.conf b/tmux.conf index 5f4cce2..9963892 100644 --- a/tmux.conf +++ b/tmux.conf @@ -151,12 +151,14 @@ if-shell 'command -v pbcopy >/dev/null' \ bind-key -Tcopy-mode-vi Escape send -X cancel # cancel v mode bind-key -Tcopy-mode-vi ^v send -X rectangle-toggle # cancel v mode -bind-key -T copy-mode-vi MouseDown1Pane select-pane -t = \; send-keys -X cancel +bind-key -T copy-mode-vi MouseDown1Pane select-pane -t = \; send-keys -X clear-selection +bind-key -T copy-mode-vi MouseUp1Pane select-pane -t = \; send-keys -X cancel bind -n MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= \"#{pane_in_mode}\" \"copy-mode -eM\" \"send-keys -M\"' 'copy-mode -eM' # (note) {{{ -# The `bind-key -T copy-m...` makes a single click leave copy-mode: back to -# the prompt, selection dropped. A drag still selects (MouseDrag1Pane below -# re-enters copy-mode) and a click on another pane still switches to it. +# A plain click (MouseDown then MouseUp, no drag) leaves copy-mode: back to +# the prompt, selection dropped. A drag sends MouseDrag/MouseDragEnd instead +# of MouseUp, so it keeps the scroll position and selects as usual. A click +# on another pane still switches to it. # The `bind -n MouseDrag1Pane if -Ft= ...` changes the default binding of # MouseDrag1Pane, the only difference is that we use `copy-mode -eM` instead # of `copy-mode -M`, so that WheelDownPane can trigger copy-mode to exit when From 1f5e8990c840c41b85289ff3d4e2fedf9c8bc0d9 Mon Sep 17 00:00:00 2001 From: bchanot Date: Tue, 6 Oct 2026 15:19:47 +0200 Subject: [PATCH 3/3] feat(tmux): alt+c copies and leaves copy-mode, alt+v pastes (cmd-less keyboards) --- tmux.conf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tmux.conf b/tmux.conf index 9963892..4a73077 100644 --- a/tmux.conf +++ b/tmux.conf @@ -145,9 +145,11 @@ bind -Tcopy-mode-vi 'v' send -X begin-selection # bind vi-like visual mode # also hands to the terminal through OSC 52 (set-clipboard), so it reaches the # local clipboard over ssh. xsel/xclip dropped: headless servers have no X. # Releasing a mouse drag copies too (selection kept on screen, copy-mode stays). +# alt+c (in a selection) = y, alt+v (anywhere, no prefix) = prefix p: cmd-less +# keyboards. GNOME Terminal: keep "Enable mnemonics" off or alt+v opens View. if-shell 'command -v pbcopy >/dev/null' \ - 'bind -Tcopy-mode-vi y send -X copy-pipe-and-cancel pbcopy ; bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-pipe-no-clear pbcopy ; bind p run "pbpaste | tmux load-buffer - ; tmux paste-buffer"' \ - 'bind -Tcopy-mode-vi y send -X copy-selection-and-cancel ; bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-selection-no-clear ; bind p paste-buffer' + 'bind -Tcopy-mode-vi y send -X copy-pipe-and-cancel pbcopy ; bind -Tcopy-mode-vi M-c send -X copy-pipe-and-cancel pbcopy ; bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-pipe-no-clear pbcopy ; bind p run "pbpaste | tmux load-buffer - ; tmux paste-buffer" ; bind -n M-v run "pbpaste | tmux load-buffer - ; tmux paste-buffer"' \ + 'bind -Tcopy-mode-vi y send -X copy-selection-and-cancel ; bind -Tcopy-mode-vi M-c send -X copy-selection-and-cancel ; bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-selection-no-clear ; bind p paste-buffer ; bind -n M-v paste-buffer' bind-key -Tcopy-mode-vi Escape send -X cancel # cancel v mode bind-key -Tcopy-mode-vi ^v send -X rectangle-toggle # cancel v mode