summaryrefslogtreecommitdiffstats
path: root/util/bin/paste
blob: b7cc6c99bb1839cc1c8a132ea38d5f88b1f148ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
set -euf

usage() {
  echo 'paste reads from stdin and pastes to the specified paste service'
  echo 'currently ix.io and paste.retiolum are supported'
  echo 'default is paste.retiolum'
  echo 'ex:'
  echo 'cat somefile | paste ix.io'
}

hoster=${1:-paste.retiolum}

case $hoster in
  paste.retiolum|paste)
    curl -sS -F 'file=@-;type=text/plain' \
        http://paste.retiolum:5000/+upload \
      | sed -n 's|.*href="\([^#]*\).*|http://paste.retiolum\1\n|p'
    ;;
  ix.io)
    curl -sS -F 'f:1=<-' ix.io
    ;;
  *)
    usage
    ;;
esac