问题
I'd like to yank text from a zsh command while in vi-mode with y and paste it into my web-browser/text-editor, etc.
Currently it seems that yanking text while in vi-mode only allows pasting back into zsh- has anyone had success yanking into the system clipboard?
回答1:
Create a widget that executes the internal vi-yank widget and copies the zle clipboard (current position in kill ring) to the X11 clipboard using xclip(1):
function vi-yank-xclip {
zle vi-yank
echo "$CUTBUFFER" | xclip -i
}
.Replace xclip -i with pbcoby if running Mac OSX.
Make that widget known to zle and bind it to y:
zle -N vi-yank-xclip
bindkey -M vicmd 'y' vi-yank-xclip
来源:https://stackoverflow.com/questions/37398532/how-do-i-yank-into-the-system-register-from-v-imode