zshuper/modules/hastebin.zsh

25 lines
613 B
Bash
Raw Normal View History

2018-02-03 15:40:00 +02:00
#
# 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