From 45c698c099ad293ca79d6f458585e113db801480 Mon Sep 17 00:00:00 2001 From: Simon Gomizelj Date: Mon, 28 Nov 2011 16:19:11 -0500 Subject: [PATCH] Reworked the sprunge script into a zsh function. There's no need to manipulate $PATH to get a zsh script loading. --- plugins/sprunge/sprunge | 75 -------------------------- plugins/sprunge/sprunge.plugin.zsh | 84 +++++++++++++++++++++++++++--- 2 files changed, 78 insertions(+), 81 deletions(-) delete mode 100755 plugins/sprunge/sprunge diff --git a/plugins/sprunge/sprunge b/plugins/sprunge/sprunge deleted file mode 100755 index 10af8e2b3..000000000 --- a/plugins/sprunge/sprunge +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/zsh - -# 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/ - -usage() { - 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 [ +# 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 () { + 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 + +INPUT METHODS + +$0 can accept piped data, STDIN redirection [