depot/third_party/nixpkgs/pkgs/shells/zsh/zsh-clipboard/clipboard.plugin.zsh
Default email 849ee4d900 Project import generated by Copybara.
GitOrigin-RevId: 9e377a6ce42dccd9b624ae4ce8f978dc892ba0e2
2021-04-08 18:26:57 +02:00

40 lines
979 B
Bash

_cb-yank() {
AA=$(clippaste 2>/dev/null) && CUTBUFFER="$AA"
zle yank
}
_cb-kill-line() {
zle kill-line
printf "%s" "$CUTBUFFER" | clipcopy 2>/dev/null
}
_cb-kill-whole-line() {
zle kill-whole-line
printf "%s" "$CUTBUFFER" | clipcopy 2>/dev/null
}
_cb-kill-word() {
zle kill-word
printf "%s" "$CUTBUFFER" | clipcopy 2>/dev/null
}
_cb-backward-kill-word() {
zle backward-kill-word
printf "%s" "$CUTBUFFER" | clipcopy 2>/dev/null
}
_cb-copy-region-as-kill() {
## https://unix.stackexchange.com/questions/19947/
zle copy-region-as-kill
zle set-mark-command -n -1
printf "%s" "$CUTBUFFER" | clipcopy 2>/dev/null
}
zle -N _cb-yank
zle -N _cb-kill-line
zle -N _cb-kill-whole-line
zle -N _cb-kill-word
zle -N _cb-backward-kill-word
zle -N _cb-copy-region-as-kill
bindkey '^y' _cb-yank
bindkey '^k' _cb-kill-line
bindkey '^u' _cb-kill-whole-line
bindkey '\ed' _cb-kill-word
bindkey '\e^?' _cb-backward-kill-word
bindkey '\ew' _cb-copy-region-as-kill