From 1a49f6443c0230b8e182294546ed9ef2a5110bf2 Mon Sep 17 00:00:00 2001 From: Matt Parnell Date: Sat, 12 Nov 2011 21:09:27 -0800 Subject: [PATCH] add sprunge.us pastebin uploader - uses files, or pipes --- plugins/sprunge/sprunge.plugin.zsh | 64 ++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 plugins/sprunge/sprunge.plugin.zsh diff --git a/plugins/sprunge/sprunge.plugin.zsh b/plugins/sprunge/sprunge.plugin.zsh new file mode 100644 index 000000000..9f9432ac8 --- /dev/null +++ b/plugins/sprunge/sprunge.plugin.zsh @@ -0,0 +1,64 @@ +# 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() { +description | fmt -s >&2 +} + +description() { +cat << HERE + +DESCRIPTION + Upload data and fetch URL from the pastebin http://sprunge.us + +USAGE + $0 filename.txt + $0 text string + $0 < filename.txt + piped_data | $0 + +NOTES +-------------------------------------------------------------------------- +* INPUT METHODS * +$0 can accept piped data, STDIN redirection [&2 + if [ "$*" ]; then + echo Arguments present... >&2 + if [ -f "$*" ]; then + echo Uploading the contents of "$*"... >&2 + cat "$*" + else + echo Uploading the text: \""$*"\"... >&2 + echo "$*" + fi | curl -F 'sprunge=<-' http://sprunge.us + else + echo No arguments found, printing USAGE and exiting. >&2 + usage + fi + else + echo Using input from a pipe or STDIN redirection... >&2 + while read -r line ; do + echo $line + done | curl -F 'sprunge=<-' http://sprunge.us + fi +}