Add Hastebin function
This commit is contained in:
parent
0504492cce
commit
e67370ec75
24
modules/hastebin.zsh
Normal file
24
modules/hastebin.zsh
Normal 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
|
Loading…
Reference in New Issue
Block a user