From 47a0a3f433f820fc78d180884f6ca376fba97b73 Mon Sep 17 00:00:00 2001 From: Vasil Zlatanov Date: Sun, 12 Apr 2015 13:05:47 +0200 Subject: Tidy up everything :) --- tools/sprunge | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 tools/sprunge (limited to 'tools/sprunge') diff --git a/tools/sprunge b/tools/sprunge new file mode 100755 index 0000000..a6e89a4 --- /dev/null +++ b/tools/sprunge @@ -0,0 +1,62 @@ +#!/bin/bash + +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 | xclip + else + echo No arguments found, will upload clipboard, also printing USAGE and exiting. >&2 + xclip -o | curl -F 'sprunge=<-' http://sprunge.us | xclip + notify-send Uploaded clipboard to sprunge + 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 | xclip +fi -- cgit v1.2.3-54-g00ecf