Browse Source

Add interactive mode.

master
Ceda ei 6 years ago
parent
commit
a84b8ad978
  1. 11
      mbin.sh

11
mbin.sh

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

Loading…
Cancel
Save