From d923956d4866beb5093c89e0c1a4f54a9c37070f Mon Sep 17 00:00:00 2001 From: Vasil Zlatanov Date: Tue, 18 Aug 2015 01:39:43 +0200 Subject: major fixes and rearrangement --- config/ratpoison/sprunge | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 config/ratpoison/sprunge (limited to 'config/ratpoison/sprunge') diff --git a/config/ratpoison/sprunge b/config/ratpoison/sprunge new file mode 100755 index 0000000..a6e89a4 --- /dev/null +++ b/config/ratpoison/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