Add clipboard mode.

This commit is contained in:
2018-11-16 15:26:30 +05:30
parent 17d4df0bba
commit e90ea86d15
2 changed files with 6 additions and 1 deletions

View File

@@ -5,7 +5,10 @@
MKR_BIN=${MKR_BIN:-https://bin.mkr.pw/}
EDITOR=${EDITOR:-vim}
if [ -t 0 ]; then
if [[ $1 == "-c" || $1 == "--clipboard" ]]; then
text=$(xclip -selection clipboard -out)
op=$(curl -s --data-binary "${text}" -H "Content-Type:text/plain" $MKR_BIN)
elif [ -t 0 ]; then
tmp_file=$(mktemp)
$EDITOR $tmp_file
op=$(curl -s --data-binary "@${tmp_file}" -H "Content-Type:text/plain" $MKR_BIN)