I've build myself this little script for zsh, to copy & paste within zsh to the system clipboard (basically got everything from here: zsh copy and paste like emacs)
x-yank() {
zle copy-region-as-kill
print -rn -- $CUTBUFFER | pbcopy
}
zle -N x-yank
x-cut() {
zle kill-region
print -rn -- $CUTBUFFER | pbcopy
}
zle -N x-cut
x-paste() {
CUTBUFFER=$(pbpaste)
zle yank
}
zle -N x-paste
bindkey -M vicmd "y" x-yank
bindkey -M vicmd "Y" x-cut
bindkey -M vicmd "p" x-paste
However, there are a few minor problems, which I can't seem to get fixed:
- Pasting will remove the current char which under the cursor, I would much prefer the Vim way, to insert it afterwards.
- Copying will not remove the selection.
Any ideas where to get started?