diff --git a/.tmux.conf b/.tmux.conf index 62c7442..0f1c154 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -57,7 +57,7 @@ bind w choose-tree -Zw bind s choose-tree -Zs bind f command-prompt -p "switch to session:" "switch-client -t '%%'" bind [ choose-buffer -bind ] paste-buffer +bind P paste-buffer # tmux buffer fallback; prefix + ] pastes the system clipboard bind C-l send-keys C-l \; clear-history # --- Copy mode ---------------------------------------------------------------- @@ -72,9 +72,12 @@ bind -T copy-mode-vi L send -X end-of-line bind -T copy-mode-vi C-u send -X halfpage-up bind -T copy-mode-vi C-d send -X halfpage-down -# Prefer a native Wayland clipboard; use xclip elsewhere. set-clipboard keeps -# OSC 52-capable terminals in sync as well. -if-shell 'command -v wl-copy >/dev/null 2>&1' 'bind -T copy-mode-vi y send -X copy-pipe-and-cancel "wl-copy"' 'bind -T copy-mode-vi y send -X copy-pipe-and-cancel "xclip -in -selection clipboard"' +# Keep tmux and the desktop clipboard in sync by default. `set-clipboard on` +# handles OSC 52-capable terminals; these bindings cover local Wayland/X11. +# Copy-mode y writes to the system clipboard. Prefix + ] reads it back and +# pastes it; prefix + P remains available for the most recent tmux buffer. +bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'if command -v wl-copy >/dev/null 2>&1; then wl-copy; elif command -v xclip >/dev/null 2>&1; then xclip -in -selection clipboard; fi' +bind ] run-shell 'if command -v wl-paste >/dev/null 2>&1; then wl-paste --no-newline | tmux load-buffer - && tmux paste-buffer; elif command -v xclip >/dev/null 2>&1; then xclip -out -selection clipboard | tmux load-buffer - && tmux paste-buffer; fi' # --- Status line -------------------------------------------------------------- set -g status on