Skip to content

Instantly share code, notes, and snippets.

@tremby
Created January 6, 2012 18:01
Show Gist options
  • Save tremby/1571669 to your computer and use it in GitHub Desktop.
Save tremby/1571669 to your computer and use it in GitHub Desktop.
sprunge -- simple sprunge script
#!/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