feat(tmux): after a mouse selection any bare key leaves copy-mode — bin/tmux-copy-exit-keys wraps the copy-mode-vi keys behind @mouse_sel (set on MouseDragEnd1Pane, cleared by pane-mode-changed hook); install.sh deploys it; docs + CHANGELOG
This commit is contained in:
1 parent
be0e5eda47
commit
ead6f96eb0
7 files changed
+104
-5
No files matched your search
@@ -154,9 +154,11 @@ bind -Tcopy-mode-vi 'v' send -X begin-selection # bind vi-like visual mode
|
||||
# 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.
|
||||
# A finished drag also marks the pane (@mouse_sel): from then on any bare key
|
||||
# leaves copy-mode, see the hook below and the run-shell at the end of file.
|
||||
if-shell 'command -v pbcopy >/dev/null' \
|
||||
'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 -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 \; set -p @mouse_sel 1 ; 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 \; set -p @mouse_sel 1 ; 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
|
||||
|
||||
@@ -179,6 +181,9 @@ bind -n MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= "#{pane_in_mode}" "c
|
||||
# Inner quotes stay plain: `\"` is literal inside '...' since tmux 3.0, and the
|
||||
# mouse-app branch (claude, vim) then dies with "syntax error" on every drag.
|
||||
# }}}
|
||||
# @mouse_sel (set by MouseDragEnd1Pane above) must not outlive the copy-mode
|
||||
# it was set in, whatever way that mode ends: cleared when the pane leaves it.
|
||||
set-hook -g pane-mode-changed 'if -F "#{!:#{pane_in_mode}}" "set -pu @mouse_sel"'
|
||||
|
||||
bind-key k "split-window -v -b -c '#{pane_current_path}'"
|
||||
bind-key h "split-window -h -b -c '#{pane_current_path}'"
|
||||
@@ -310,3 +315,8 @@ set-option -g message-command-style bg=default,fg=brightwhite
|
||||
|
||||
run '~/.config/tmux/plugins/tpm/tpm'
|
||||
|
||||
# After a mouse selection any bare key leaves copy-mode (keyboard/wheel
|
||||
# copy-mode keeps its vi keys). Wraps the bindings as they stand, so it runs
|
||||
# last, after the plugins. Script deployed by install.sh with the other bins.
|
||||
run-shell '~/.local/bin/tmux-copy-exit-keys'
|
||||
|
||||
Reference in new issue
Block a user