dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

pastebin (1018B)


      1 #!/usr/bin/env bash
      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     local opts
     12     local OPTIND
     13     [ -f "$HOME/.netrc" ] && opts='-n'
     14     while getopts ":hd:i:n:" x; do
     15         case $x in
     16             h) echo "ix [-d ID] [-i ID] [-n N] [opts]"; return;;
     17             d) $echo curl $opts -X DELETE ix.io/$OPTARG; return;;
     18             i) opts="$opts -X PUT"; local id="$OPTARG";;
     19             n) opts="$opts -F read:1=$OPTARG";;
     20         esac
     21     done
     22     shift $(($OPTIND - 1))
     23     [ -t 0 ] && {
     24         local filename="$1"
     25         shift
     26         [ "$filename" ] && {
     27             curl $opts -F f:1=@"$filename" $* ix.io/$id
     28             return
     29         }
     30         echo "^C to cancel, ^D to send."
     31     }
     32     curl $opts -F f:1='<-' $* ix.io/$id
     33 }
     34 
     35 ix $*