diff --git a/tmux.conf b/tmux.conf index b7020d2..4a73077 100644 --- a/tmux.conf +++ b/tmux.conf @@ -145,16 +145,22 @@ 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 -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 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...` let a single click do selection clearing for us. +# 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