Created
January 6, 2012 18:01
-
-
Save tremby/1571669 to your computer and use it in GitHub Desktop.
sprunge -- simple sprunge script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
url=$(curl -F 'sprunge=<-' -H "Expect: " http://sprunge.us 2>/dev/null) | |
if [ $? -ne 0 ]; then | |
echo "request failed" >&2 | |
exit 1 | |
fi | |
if [ $# -gt 0 ]; then | |
url="$url?$1" | |
fi | |
echo $url | |
if [ $DISPLAY ]; then | |
{ type xsel >/dev/null 2>/dev/null && echo -n $url | xsel; } \ | |
|| { type xclip >/dev/null 2>/dev/null && echo -n $url | xclip; } \ | |
|| echo "haven't copied to the clipboard: no xsel or xclip" >&2 | |
else | |
echo "haven't copied to the clipboard: no \$DISPLAY" >&2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment