diff --git a/modules/hastebin.zsh b/modules/hastebin.zsh new file mode 100644 index 0000000..d465773 --- /dev/null +++ b/modules/hastebin.zsh @@ -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