mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +01:00
Fixed up sprunge command. Condensed it and fixed the whitespace.
This commit is contained in:
parent
0665660118
commit
258fda38d0
1 changed files with 21 additions and 15 deletions
|
|
@ -88,22 +88,28 @@ HERE
|
||||||
done | curl -s -F 'sprunge=<-' http://sprunge.us)
|
done | curl -s -F 'sprunge=<-' http://sprunge.us)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$syntax" != "text" ]]; then
|
local flags
|
||||||
# if stdout is not a tty, suppress trailing newline
|
|
||||||
if [[ ! -t 1 ]] ; then local flags='-n' ; fi
|
# trim whitespaces and add syntax info
|
||||||
echo $flags "$url?$syntax"
|
url=${url//[[:space:]]}
|
||||||
else
|
[[ $syntax != text ]] && url=${url}?${syntax}
|
||||||
# if stdout is not a tty, suppress trailing newline
|
|
||||||
if [[ ! -t 1 ]] ; then local flags='-n' ; fi
|
# if stdout is not a tty, suppress trailing newline
|
||||||
echo $flags $url
|
# XXX: i don't think this is the right thing to do
|
||||||
fi
|
# [[ ! -t 1 ]] && flags='-n'
|
||||||
|
|
||||||
|
# output
|
||||||
|
echo $flags $url
|
||||||
|
|
||||||
|
# don't copy to clipboad if piped
|
||||||
|
[[ ! -t 1 ]] && return 0
|
||||||
|
|
||||||
#copy url to primary and clipboard (middle-mouse & shift+ins/Ctrl+v)
|
#copy url to primary and clipboard (middle-mouse & shift+ins/Ctrl+v)
|
||||||
if (( $+commands[xclip] )); then
|
if (( $+commands[xclip] )); then
|
||||||
echo -n "$url?$syntax" | xclip -sel primary
|
echo -n $url | xclip -sel primary
|
||||||
echo -n "$url?$syntax" | xclip -sel clipboard
|
echo -n $url | xclip -sel clipboard
|
||||||
elif (( $+commands[xsel] )); then
|
elif (( $+commands[xsel] )); then
|
||||||
echo -n "$url?$syntax" | xsel -ip #primary
|
echo -n $url | xsel -ip #primary
|
||||||
echo -n "$url?$syntax" | xsel -ib #clipboard
|
echo -n $url | xsel -ib #clipboard
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue