bin-client/mbin.sh

19 lines
554 B
Bash
Executable File

#!/usr/bin/env bash
# Set MKR_BIN if not set. Export it in your shell rc to use a self hosted
# instance. Include the trailing slash with custom urls.
MKR_BIN=${MKR_BIN:-https://bin.mkr.pw/}
EDITOR=${EDITOR:-vim}
if [ -t 0 ]; then
tmp_file=$(mktemp)
$EDITOR $tmp_file
op=$(curl -s --data-binary "@${tmp_file}" -H "Content-Type:text/plain" $MKR_BIN)
rm $tmp_file
else
op=$(curl -s --data-binary "@-" -H "Content-Type:text/plain" $MKR_BIN)
fi
link=$(echo $op | cut -f2 -d'/')
echo ${MKR_BIN}${link} | tee /dev/tty | xclip -selection clipboard