hhgph (523B)
1 #!/bin/sh 2 # usage: <command> | hlpaste [file extension] 3 # hlpaste [file extension] < /path/to/file 4 5 cp /dev/stdin /tmp/hlpaste 6 id=$(sha512sum < /tmp/hlpaste | grep -Eo '^.{15}') 7 fileext="${1:-txt}" 8 gtype=$(file /tmp/hlpaste | 9 tr '[:upper:]' '[:lower:]' | 10 sed -E 's~.*(binary|video|audio).*~9~;s~.*image.*~I~' | 11 grep -o '^.$' || echo "0") 12 13 file="$id.$fileext" 14 path="$HOME/net/gopher/paste/$file" 15 uri="gopher://hhvn.uk/$gtype/paste/$file" 16 mv /tmp/hlpaste "$path" 17 18 echo "$uri" | tee /dev/stderr | tr -d '\n' | xclip