mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-12 21:39:48 +01:00
clipboard: Reduce unnecessary special-casing on stdin
Ideally the parameter would just be removed-users could always just do "clipcopy < some-file". but removing the parameter would break backwards compatibility. In any case, this simplifies the logic considerably.
This commit is contained in:
parent
29fb617e6b
commit
d855547661
1 changed files with 6 additions and 21 deletions
|
@ -17,32 +17,17 @@
|
||||||
#
|
#
|
||||||
function clipcopy() {
|
function clipcopy() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
local file=$1
|
local file="${1:-/dev/stdin}"
|
||||||
|
|
||||||
if [[ $OSTYPE == darwin* ]]; then
|
if [[ $OSTYPE == darwin* ]]; then
|
||||||
if [[ -z $file ]]; then
|
pbcopy < "${file}"
|
||||||
pbcopy
|
|
||||||
else
|
|
||||||
cat $file | pbcopy
|
|
||||||
fi
|
|
||||||
elif [[ $OSTYPE == cygwin* ]]; then
|
elif [[ $OSTYPE == cygwin* ]]; then
|
||||||
if [[ -z $file ]]; then
|
cat "${file}" > /dev/clipboard
|
||||||
cat > /dev/clipboard
|
|
||||||
else
|
|
||||||
cat $file > /dev/clipboard
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if (( $+commands[xclip] )); then
|
if (( $+commands[xclip] )); then
|
||||||
if [[ -z $file ]]; then
|
xclip -in -selection clipboard < "${file}"
|
||||||
xclip -in -selection clipboard
|
|
||||||
else
|
|
||||||
xclip -in -selection clipboard $file
|
|
||||||
fi
|
|
||||||
elif (( $+commands[xsel] )); then
|
elif (( $+commands[xsel] )); then
|
||||||
if [[ -z $file ]]; then
|
xsel --clipboard --input < "${file}"
|
||||||
xsel --clipboard --input
|
|
||||||
else
|
|
||||||
cat "$file" | xsel --clipboard --input
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2
|
print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2
|
||||||
return 1
|
return 1
|
||||||
|
|
Loading…
Reference in a new issue