tmux: Emulate normal-mode y without selection
Try to mimic vim's normal and visual mode behaviour of `y`. Set 'copy-command' for the copy-pipe commands to fall back to.
This commit is contained in:
@@ -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 \
|
||||
|
||||
Reference in New Issue
Block a user