Change code structure, style
This commit is contained in:
parent
64db1f9723
commit
87cefda5f4
2 changed files with 25 additions and 32 deletions
|
@ -3,7 +3,4 @@ Clipboard
|
|||
|
||||
Integrates zsh clipboard with system clipboard.
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
||||
Make sure to set IS_MAC_OS correctly in init.zsh.
|
||||
On OSX, uses pbcopy and pbpaste. On cygwin, uses /dev/clipboard. On linux, requires either xclip or xsel be installed.
|
||||
|
|
|
@ -5,20 +5,18 @@
|
|||
# Nir Friedman <quicknir@gmail.com>
|
||||
#
|
||||
|
||||
# If running Mac OS, set this to 1
|
||||
local IS_MAC_OS=0
|
||||
|
||||
if [[ IS_MAC_OS -eq 0 ]]; then
|
||||
function cutbuffer() {
|
||||
zle .$WIDGET
|
||||
echo $CUTBUFFER | xclip -selection clipboard
|
||||
}
|
||||
else
|
||||
function cutbuffer() {
|
||||
function cutbuffer {
|
||||
zle .$WIDGET
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
echo $CUTBUFFER | pbcopy
|
||||
}
|
||||
fi
|
||||
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
|
||||
}
|
||||
|
||||
zle_cut_widgets=(
|
||||
vi-backward-delete-char
|
||||
|
@ -33,30 +31,28 @@ zle_cut_widgets=(
|
|||
vi-yank-eol
|
||||
)
|
||||
|
||||
for widget in $zle_cut_widgets
|
||||
do
|
||||
for widget in $zle_cut_widgets; do
|
||||
zle -N $widget cutbuffer
|
||||
done
|
||||
|
||||
|
||||
if [[ IS_MAC_OS -eq 0 ]]; then
|
||||
function putbuffer() {
|
||||
function putbuffer {
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
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)"
|
||||
elif (( $+commands[xsel] )); then
|
||||
zle copy-region-as-kill "$(xsel --clipboard --output)"
|
||||
fi
|
||||
zle .$WIDGET
|
||||
}
|
||||
else
|
||||
function putbuffer() {
|
||||
zle copy-region-as-kill "$(pbpaste)"
|
||||
zle .$WIDGET
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
zle_put_widgets=(
|
||||
vi-put-after
|
||||
vi-put-before
|
||||
)
|
||||
|
||||
for widget in $zle_put_widgets
|
||||
do
|
||||
for widget in $zle_put_widgets; do
|
||||
zle -N $widget putbuffer
|
||||
done
|
||||
|
|
Loading…
Add table
Reference in a new issue