From a84b8ad978de89ea22bc87004da56a5d4c2f6057 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Fri, 16 Nov 2018 14:56:36 +0530 Subject: [PATCH] Add interactive mode. --- mbin.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mbin.sh b/mbin.sh index 1878308..5d5e899 100755 --- a/mbin.sh +++ b/mbin.sh @@ -3,7 +3,16 @@ # 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 -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'/') echo ${MKR_BIN}${link} | tee /dev/tty | xclip -selection clipboard