fix vi mode zsh copy and paste

master
tiynger 5 years ago
parent ef882fe187
commit 97dcfc694f

@ -1,4 +1,3 @@
# Disable ctrl-s and ctrl-q.
stty -ixon
@ -49,6 +48,42 @@ zle -N zle-line-init
echo -ne '\e[5 q'
preexec() { echo -ne '\e[5 q' ;}
# Vim copy and paste fix in terminal
function x11-clip-wrap-widgets() {
local copy_or_paste=$1
shift
for widget in $@; do
if [[ $copy_or_paste == "copy" ]]; then
eval "
function _x11-clip-wrapped-$widget() {
zle .$widget
xclip -in -selection clipboard <<<\$CUTBUFFER
}
"
else
eval "
function _x11-clip-wrapped-$widget() {
CUTBUFFER=\$(xclip -out -selection clipboard)
zle .$widget
}
"
fi
zle -N $widget _x11-clip-wrapped-$widget
done
}
local copy_widgets=(
vi-yank vi-yank-eol vi-delete vi-backward-kill-word vi-change-whole-line
)
local paste_widgets=(
vi-put-{before,after}
)
# NB: can atm. only wrap native widgets
x11-clip-wrap-widgets copy $copy_widgets
x11-clip-wrap-widgets paste $paste_widgets
# starts one or multiple args in background
background() {
for ((i=2;i<=$#;i++)); do

Loading…
Cancel
Save