How do I yank into the system register from v-imode?

你离开我真会死。 提交于 2021-02-05 06:37:45

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!