ix (868B)
1 #!/bin/sh 2 3 # Examples: 4 # ix hello.txt # paste file (name/ext will be set). 5 # echo Hello world. | ix # read from STDIN (won't set name/ext). 6 # ix -n 1 self_destruct.txt # paste will be deleted after one read. 7 # ix -i ID hello.txt # replace ID, if you have permission. 8 # ix -d ID 9 10 ix() { 11 while getopts ":hd:i:n:" x; do 12 case $x in 13 h) echo "ix [-d ID] [-i ID] [-n N] [opts]"; return;; 14 d) $echo curl $opts -X DELETE ix.io/$OPTARG; return;; 15 i) opts="$opts -X PUT"; local id="$OPTARG";; 16 n) opts="$opts -F read:1=$OPTARG";; 17 esac 18 done 19 if [ -t 0 ]; then 20 if [ -f "$1" ]; then 21 curl $opts -F f:1=@"$1" $* ix.io/$id 22 return 23 fi 24 echo "^C to cancel, ^D to send." 25 fi 26 curl $opts -F f:1='<-' $* ix.io/$id 27 } 28 29 ix $*