dotfiles

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

upload (527B)


      1 #!/bin/sh
      2 if ! command -v curl 1>/dev/null 2>&1; then
      3   echo "curl not installed." >&2
      4   exit 1
      5 fi
      6 if ! command -v clc 1>/dev/null 2>&1; then
      7   echo "clc script not present." >&2
      8   exit 1
      9 fi
     10 
     11 die() {
     12   echo "$1" >&2
     13   exit 1
     14 }
     15 
     16 [ $# -eq 1 ] || die "File not provided as first argument."
     17 [ -f "$1" ] || die "File $1 does not exist."
     18 response=$(curl -s -F file=@"$1" http://0x0.st)
     19 printf 'Response: %s' "$response"
     20 { printf '%s' "$response" | sed 's/^.*\(http[^"]*\).*/\1/' | clc; } || echo "Direct link copied to clipboard."
     21 
     22