# Smart sprunge alias/script. # # To add the sprunge script to your path, add this to your .zshrc file: # # zstyle :omz:plugins:sprunge add-path on # # Otherwise, a simple alias for sprunge, but only if there isn't a smarter, # better one out there in $PATH, will be added. # zstyle -b :omz:plugins:sprunge add-path _plugin__path # if [[ ${_plugin__path} == "on" ]]; then # Plugin setting: Add this plugin directory to the path # export PATH=$PATH:$ZSH/plugins/sprunge # elif [[ -z "${commands[sprunge]}" ]]; then # Nope. No `sprunge` command, period. So, dumb/simple alias, here we go! # alias sprunge="curl -F 'sprunge=<-' http://sprunge.us/" # fi # # 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/ sprunge () { local url syntax if [[ -t 0 ]]; then if [[ -n "$*" ]]; 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=$(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 INPUT METHODS $0 can accept piped data, STDIN redirection [