This is a shell script, not a function anymore

This commit is contained in:
Colin Shea 2011-11-27 03:41:31 -07:00
commit de3c49c38d

View file

@ -47,31 +47,29 @@ HERE
exit exit
} }
sprunge() { if [ -t 0 ]; then
if [ -t 0 ]; then if [ "$*" ]; then
if [ "$*" ]; then if [ -f "$*" ]; then
if [ -f "$*" ]; then # Use python to attempt to detect the syntax
# Use python to attempt to detect the syntax syntax=$(echo "try:
syntax=$(echo "try: from pygments.lexers import get_lexer_for_filename
from pygments.lexers import get_lexer_for_filename print(get_lexer_for_filename('$*').aliases[0])
print(get_lexer_for_filename('$*').aliases[0]) except:
except: print('text')" | python)
print('text')" | python) url=$(cat "$*" | curl -F 'sprunge=<-' http://sprunge.us)
url=$(cat "$*" | curl -F 'sprunge=<-' http://sprunge.us)
fi
else
usage
fi fi
else else
syntax="text" # We're dumb in this mode. So, dumb syntax highlighting! usage
url=$(while read -r line ; do
echo $line
done | curl -F 'sprunge=<-' http://sprunge.us)
fi fi
else
syntax="text" # We're dumb in this mode. So, dumb syntax highlighting!
url=$(while read -r line ; do
echo $line
done | curl -F 'sprunge=<-' http://sprunge.us)
fi
if [ "$syntax" != "text" ]; then if [ "$syntax" != "text" ]; then
echo "$url?$syntax" echo "$url?$syntax"
else else
echo $url echo $url
fi fi
}