From b900c6d3a3f36246d7de3409b74a20737ec8b410 Mon Sep 17 00:00:00 2001 From: bchanot Date: Tue, 6 Oct 2026 15:02:42 +0200 Subject: [PATCH] fix(tmux): visible selection colour, mouse drag copies on release - mode-style bg=yellow,fg=black (black on a dark terminal was invisible) - MouseDragEnd1Pane copies (pbcopy on macOS, tmux buffer elsewhere) without leaving copy-mode --- tmux.conf | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tmux.conf b/tmux.conf index 5173bd1..b7020d2 100644 --- a/tmux.conf +++ b/tmux.conf @@ -108,7 +108,9 @@ unbind p # (pasting) unbind % # (sp) unbind '"' # (vs) unbind-key -T copy-mode-vi MouseDragEnd1Pane # (mouse setting) {{{ -# disable "release mouse drag to copy and exit copy-mode" +# stock binding = "release the drag: copy AND leave copy-mode", which loses +# the selection on screen. Rebound below (clipboard section) as copy without +# leaving, so a drag is enough and y stays available. # ref: https://github.com/tmux/tmux/issues/140 # }}} @@ -142,9 +144,10 @@ bind -Tcopy-mode-vi 'v' send -X begin-selection # bind vi-like visual mode # Clipboard: pbcopy/pbpaste on macOS. Elsewhere tmux's own buffer, which tmux # 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). if-shell 'command -v pbcopy >/dev/null' \ - 'bind -Tcopy-mode-vi y send -X copy-pipe-and-cancel pbcopy ; bind p run "pbpaste | tmux load-buffer - ; tmux paste-buffer"' \ - 'bind -Tcopy-mode-vi y send -X copy-selection-and-cancel ; bind p paste-buffer' + '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-key -Tcopy-mode-vi Escape send -X cancel # cancel v mode bind-key -Tcopy-mode-vi ^v send -X rectangle-toggle # cancel v mode @@ -236,7 +239,7 @@ set -g @resurrect-dir "$XDG_CACHE_HOME/tmux/$TMUX_SOCKET_NAME" # Status Bar: {{{ # ---------- -set -wg mode-style bg=black,fg=brightwhite +set -wg mode-style bg=yellow,fg=black # selection: same accent as the status bar set-window-option -g window-status-separator '' set -g status-position bottom set -g status-left-length 42