|
|
@ -5,20 +5,18 @@
|
|
|
|
# Nir Friedman <quicknir@gmail.com>
|
|
|
|
# Nir Friedman <quicknir@gmail.com>
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
# If running Mac OS, set this to 1
|
|
|
|
function cutbuffer {
|
|
|
|
local IS_MAC_OS=0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ IS_MAC_OS -eq 0 ]]; then
|
|
|
|
|
|
|
|
function cutbuffer() {
|
|
|
|
|
|
|
|
zle .$WIDGET
|
|
|
|
|
|
|
|
echo $CUTBUFFER | xclip -selection clipboard
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
function cutbuffer() {
|
|
|
|
|
|
|
|
zle .$WIDGET
|
|
|
|
zle .$WIDGET
|
|
|
|
|
|
|
|
if [[ "$OSTYPE" == darwin* ]]; then
|
|
|
|
echo $CUTBUFFER | pbcopy
|
|
|
|
echo $CUTBUFFER | pbcopy
|
|
|
|
}
|
|
|
|
elif [[ "$OSTYPE" == cygwin* ]]; then
|
|
|
|
|
|
|
|
echo $CUTBUFFER | tee > /dev/clipboard
|
|
|
|
|
|
|
|
elif (( $+commands[xclip] )); then
|
|
|
|
|
|
|
|
echo $CUTBUFFER | xclip -selection clipboard
|
|
|
|
|
|
|
|
elif (( $+commands[xsel] )); then
|
|
|
|
|
|
|
|
echo $CUTBUFFER | xsel --clipboard --input
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
zle_cut_widgets=(
|
|
|
|
zle_cut_widgets=(
|
|
|
|
vi-backward-delete-char
|
|
|
|
vi-backward-delete-char
|
|
|
@ -33,30 +31,28 @@ zle_cut_widgets=(
|
|
|
|
vi-yank-eol
|
|
|
|
vi-yank-eol
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
for widget in $zle_cut_widgets
|
|
|
|
for widget in $zle_cut_widgets; do
|
|
|
|
do
|
|
|
|
|
|
|
|
zle -N $widget cutbuffer
|
|
|
|
zle -N $widget cutbuffer
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function putbuffer {
|
|
|
|
if [[ IS_MAC_OS -eq 0 ]]; then
|
|
|
|
if [[ "$OSTYPE" == darwin* ]]; then
|
|
|
|
function putbuffer() {
|
|
|
|
zle copy-region-as-kill "$(pbcopy)"
|
|
|
|
|
|
|
|
elif [[ "$OSTYPE" == cygwin* ]]; then
|
|
|
|
|
|
|
|
zle copy-region-as-kill "$(cat /dev/clipboard)"
|
|
|
|
|
|
|
|
elif (( $+commands[xclip] )); then
|
|
|
|
zle copy-region-as-kill "$(xclip -o -selection clipboard)"
|
|
|
|
zle copy-region-as-kill "$(xclip -o -selection clipboard)"
|
|
|
|
|
|
|
|
elif (( $+commands[xsel] )); then
|
|
|
|
|
|
|
|
zle copy-region-as-kill "$(xsel --clipboard --output)"
|
|
|
|
|
|
|
|
fi
|
|
|
|
zle .$WIDGET
|
|
|
|
zle .$WIDGET
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
function putbuffer() {
|
|
|
|
|
|
|
|
zle copy-region-as-kill "$(pbpaste)"
|
|
|
|
|
|
|
|
zle .$WIDGET
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
zle_put_widgets=(
|
|
|
|
zle_put_widgets=(
|
|
|
|
vi-put-after
|
|
|
|
vi-put-after
|
|
|
|
vi-put-before
|
|
|
|
vi-put-before
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
for widget in $zle_put_widgets
|
|
|
|
for widget in $zle_put_widgets; do
|
|
|
|
do
|
|
|
|
|
|
|
|
zle -N $widget putbuffer
|
|
|
|
zle -N $widget putbuffer
|
|
|
|
done
|
|
|
|
done
|
|
|
|