# Contributed and SLIGHTLY modded by Matt Parnell/ilikenwf # Created by the blogger at the URL below...I don't know where to find his/her name # Original found at http://www.shellperson.net/sprunge-pastebin-script/ # # Modified by Evaryont to: # - Detect syntax via pygments # - Behave nicely as a plugin sprunge() { if [ -t 0 ]; then if [ "$*" ]; then if [ -f "$*" ]; then # Use python to attempt to detect the syntax syntax=$(echo "try: from pygments.lexers import get_lexer_for_filename print(get_lexer_for_filename('$*').aliases[0]) except: print('text')" | python) url=$(cat "$*" | curl -F 'sprunge=<-' http://sprunge.us) fi else cat << HERE DESCRIPTION Upload data and fetch URL from the pastebin http://sprunge.us USAGE $0 filename.txt $0 < filename.txt piped_data | $0 NOTES -------------------------------------------------------------------------- * INPUT METHODS * $0 can accept piped data, STDIN redirection [&2 return 0 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" -ne "text" ]; then echo "$url?$syntax" else echo $url fi }