mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-03-20 03:13:33 +01:00
PLUGINS: vi-mode: Allow Copy/Paste with the clipboard
Enable to use vim commands ( y/p/d/c/s ) to interact with the X window system clipboard, thus with other applications.
This commit is contained in:
parent
814d426679
commit
0f6e49b455
1 changed files with 42 additions and 0 deletions
|
|
@ -63,3 +63,45 @@ function vi_mode_prompt_info() {
|
|||
if [[ "$RPS1" == "" && "$RPROMPT" == "" ]]; then
|
||||
RPS1='$(vi_mode_prompt_info)'
|
||||
fi
|
||||
|
||||
|
||||
# Allow Copy/Paste with the system clipboard
|
||||
# behave as expected with vim commands ( y/p/d/c/s )
|
||||
[[ -n $DISPLAY ]] && (( $+commands[xclip] )) && {
|
||||
|
||||
function cutbuffer() {
|
||||
zle .$WIDGET
|
||||
echo $CUTBUFFER | xclip -selection clipboard
|
||||
}
|
||||
|
||||
zle_cut_widgets=(
|
||||
vi-backward-delete-char
|
||||
vi-change
|
||||
vi-change-eol
|
||||
vi-change-whole-line
|
||||
vi-delete
|
||||
vi-delete-char
|
||||
vi-kill-eol
|
||||
vi-substitute
|
||||
vi-yank
|
||||
vi-yank-eol
|
||||
)
|
||||
for widget in $zle_cut_widgets
|
||||
do
|
||||
zle -N $widget cutbuffer
|
||||
done
|
||||
|
||||
function putbuffer() {
|
||||
zle copy-region-as-kill "$(xclip -o)"
|
||||
zle .$WIDGET
|
||||
}
|
||||
|
||||
zle_put_widgets=(
|
||||
vi-put-after
|
||||
vi-put-before
|
||||
)
|
||||
for widget in $zle_put_widgets
|
||||
do
|
||||
zle -N $widget putbuffer
|
||||
done
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue