mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
clip*: add xsel support
This commit is contained in:
parent
e4fdb08365
commit
b6d78df62c
2 changed files with 33 additions and 14 deletions
|
@ -31,16 +31,22 @@ function clipcopy() {
|
||||||
cat $file > /dev/clipboard
|
cat $file > /dev/clipboard
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
which xclip &>/dev/null
|
if which xclip &>/dev/null; then
|
||||||
if [[ $? != 0 ]]; then
|
|
||||||
print "clipcopy: Platform $OSTYPE not supported or xclip not installed" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [[ -z $file ]]; then
|
if [[ -z $file ]]; then
|
||||||
xclip -in -selection clipboard
|
xclip -in -selection clipboard
|
||||||
else
|
else
|
||||||
xclip -in -selection clipboard $file
|
xclip -in -selection clipboard $file
|
||||||
fi
|
fi
|
||||||
|
elif which xsel &>/dev/null; then
|
||||||
|
if [[ -z $file ]]; then
|
||||||
|
xsel --clipboard --input
|
||||||
|
else
|
||||||
|
cat "$file" | xsel --clipboard --input
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +56,17 @@ function clipcopy() {
|
||||||
#
|
#
|
||||||
# clippaste - writes clipboard's contents to stdout
|
# clippaste - writes clipboard's contents to stdout
|
||||||
#
|
#
|
||||||
|
# clippaste | <command> - pastes contents and pipes it to another process
|
||||||
|
#
|
||||||
|
# clippaste > <file> - paste contents to a file
|
||||||
|
#
|
||||||
|
# Examples:
|
||||||
|
#
|
||||||
|
# # Pipe to another process
|
||||||
|
# clippaste | grep foo
|
||||||
|
#
|
||||||
|
# # Paste to a file
|
||||||
|
# clippaste > file.txt
|
||||||
function clippaste() {
|
function clippaste() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
if [[ $OSTYPE == darwin* ]]; then
|
if [[ $OSTYPE == darwin* ]]; then
|
||||||
|
@ -57,11 +74,13 @@ function clippaste() {
|
||||||
elif [[ $OSTYPE == cygwin* ]]; then
|
elif [[ $OSTYPE == cygwin* ]]; then
|
||||||
cat /dev/clipboard
|
cat /dev/clipboard
|
||||||
else
|
else
|
||||||
which xclip &>/dev/null
|
if which xclip &>/dev/null; then
|
||||||
if [[ $? != 0 ]]; then
|
xclip -out -selection clipboard
|
||||||
print "clipcopy: Platform $OSTYPE not supported or xclip not installed" >&2
|
elif which xsel &>/dev/null; then
|
||||||
|
xsel --clipboard --output
|
||||||
|
else
|
||||||
|
print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
xclip -out -selection clipboard
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
Loading…
Reference in a new issue