3 ms·
I like the ix.io pastebin, since it has a nice rest interface and the url is concise. I have a wrapper function that lets you run ix [<path>] and will sum
by xelxebar 8y ago
I like the ix.io pastebin, since it has a nice rest interface and the url is concise. I have a wrapper function that lets you run
ix [<path>]
and will sumbit the content of the supplied path, or stdin if no path is given.
Here's function at said pastebin (http://ix.io/1yiG/sh http://ix.io/1yiG/sh), and in raw form below:
ix() {
curl=$(command -v curl)
[ -f "$HOME/.netrc" ] && curl="${curl} --netrc"
while getopts ":d:i:n:e:" opt; do
case "${opt}" in
d) ${curl} --request DELETE "ix.io/${OPTARG}"; return;;
i) curl="${curl} --request PUT"; id="${OPTARG}";;
n) curl="${curl} --form read:1=${OPTARG}";;
e) curl="${curl} --form ext:1=${OPTARG}";;
:) error "Expected argument: -${OPTARG}"; return 1;;
*) echo 'Usage: ix [-d ID] [-i ID] [-n N] [<options>]';
return;;
esac
done
shift $((OPTIND - 1))
unset -v OPTIND OPTERR
if [ -t 0 ]; then
filename="$1"; shift
if [ "$filename" ]; then
${curl} --form f:1=@"$filename" "${@}" "ix.io/${id}"
return
fi
echo "^C to cancel, ^D to send."
fi
${curl} --form f:1='<-' "${@}" "ix.io/${id}"
unset -v curl opt id filename
}