diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index 4ae6275..907cb81 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -10,6 +10,9 @@ run-shell 'mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/tmux"' # Better clipboard on mousedrag (https://unix.stackexchange.com/a/349020) # Disable xterm escape sequences for setting clipboard set -s set-clipboard off + +set -g copy-command 'xclip -selection clipboard' + # Copy selection into primary selection (without aborting) bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-no-clear "xclip -se p" @@ -85,7 +88,17 @@ bind Escape copy-mode unbind -T copy-mode-vi v bind -T copy-mode-vi v send -X begin-selection # Yank into system clipboard -bind -T copy-mode-vi y send -X copy-pipe "xclip -selection clipboard" +# TODO: This breaks on repeatable movements (e.g. `y2e`) +bind -T copy-mode-vi y \ + if -F "#{selection_present}" { + send -X copy-pipe + } { + command-prompt -k -p (operator-pending) { + send -X begin-selection + send "%%" + send -X copy-pipe + } + } # Clear selection or cancel copy-mode when nothing is selected bind -T copy-mode-vi Escape \