Add Hastebin function

This commit is contained in:
Mark Vainomaa 2018-02-03 15:40:00 +02:00
parent 0504492cce
commit e67370ec75
Signed by: mikroskeem
GPG Key ID: 1B3F9523B542D315

24
modules/hastebin.zsh Normal file
View File

@ -0,0 +1,24 @@
#
# Hastebin pasting module
#
ZSPR_HASTEBIN_DOMANIN="https://paste.wut.ee"
function haste {
local file="${1}"
if [ ! -z "${file}" -o ! -t 0 ]; then
if [ ! -z "${file}" ]; then
local input="${file}"
else
local input="-"
fi
local output="$(cat "${input}" | curl -X POST --data-binary @- "${ZSPR_HASTEBIN_DOMANIN}/documents")"
echo -e "\n${ZSPR_HASTEBIN_DOMANIN}/$(echo "${output}" | jq -r .key)"
else
echo "Usage: haste [file]"
echo "haste can take input from stdin as well"
return 0
fi
}
autoload -Uz haste