Create a gist now

Instantly share code, notes, and snippets.

@ushis /put.zsh
Last active Mar 31, 2017

What would you like to do?
# Uploads files to honkgong.
#
# Specify some files like so:
#
# put <file> [<file> ...]
#
# Or pipe some data into it:
#
# cat file1 file2 | put
#
# Have a nice day!
put() {
local f url='https://put.honkgong.info'
# Read from stdin, if there are no arguments.
if [ $# -eq 0 ]; then
curl --data-binary @- "${url}"
return $?
fi
# Try to send every provided file.
for f in $*; do
if [ ! -r "${f}" ]; then
print "Can't read:" "${f}" 1>&2
else
curl -T "${f}" -H "Content-Type: $(file -b --mime-type ${f})" "${url}"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment