From f97d1bde88e8ea64d3afe348993f550928880af7 Mon Sep 17 00:00:00 2001 From: Aman Hanjrah Date: Tue, 5 Jun 2018 10:15:39 -0700 Subject: [PATCH] sprunge alike as sprunge is out of order --- plugins/ixio/ixio.plugin.zsh | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 plugins/ixio/ixio.plugin.zsh diff --git a/plugins/ixio/ixio.plugin.zsh b/plugins/ixio/ixio.plugin.zsh new file mode 100644 index 000000000..cebf6196b --- /dev/null +++ b/plugins/ixio/ixio.plugin.zsh @@ -0,0 +1,66 @@ +# Updated for ix.io as sprunge is not working anymore [https://github.com/rupa/sprunge/issues/43] +# Modded by ahanjrah +# Kudos to the original creator/maintainer +# +# 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://ix.io + +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 'f:1=<-' ix.io + else + echo No arguments found, printing USAGE and exiting. >&2 + usage + fi + else + echo Using input from a pipe or STDIN redirection... >&2 + curl -F 'f:1=<-' ix.io + fi +}