dotfiles/.config/zsh/functions/puttmpninja
2022-04-14 04:55:05 +02:00

23 lines
684 B
Bash
Executable File

#!/usr/bin/env zsh
# Put files on tmp.ninja
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
zmodload zsh/zutil
local -a o_help=()
zparseopts -D -K -- h=o_help
if [[ ${#o_help} -ne 0 || ! -v 1 ]]; then
ret=$(( ${#o_help} ^ 1 ))
print -u $(( 1 + ${ret} )) -l "usage: ${0} [-h] <FILE> …" \
"\e[3mFiles on tmp.ninja expire after 48 hours.\e[0m"
return ${ret}
fi
for file in ${@}; do
print -n '\e[0;94m'
local url=$(curl --progress-bar --form "files[]=@${file}" \
'https://tmp.ninja/upload.php?output=text')
print '\e[1;95m→\e[0m' "\e[0;97m${url}\e[0m" \
"\e[3;90mexpires: $(date --date='now + 2 days')\e[0m"
done