tmux: Support repeatable yank motions via yank.sh

Implementing logic inside tmux's config starts to become tedious with
growing complexity. Introduce a shell script that handles the logic of
the (now also repeatable) vim-like bindings.
This commit is contained in:
2024-07-04 14:30:56 +02:00
parent 91d34358ec
commit ec637ad1c8
2 changed files with 56 additions and 17 deletions

View File

@@ -132,23 +132,8 @@ bind -T copy-mode-vi C-v {
send -X rectangle-toggle
}
# Yank into system 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) {
# do line-wise yank on yy
if -F "#{==:%1,y}" {
send -X select-line
} {
send -X begin-selection
send "%1"
}
send -X copy-pipe
}
}
# Yank into system clipboard with vim-like bindings
bind -T copy-mode-vi y run-shell '${XDG_CONFIG_HOME:-$HOME/.config}/tmux/yank.sh'
bind -T copy-mode-vi Y \
if -F "#{selection_present}" { send -X copy-pipe-line } { send -X copy-pipe-end-of-line }