Skip to content

Instantly share code, notes, and snippets.

@sofar
Created December 31, 2017 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sofar/113c9be7256a37ef1d3e2c328ea5b322 to your computer and use it in GitHub Desktop.
Save sofar/113c9be7256a37ef1d3e2c328ea5b322 to your computer and use it in GitHub Desktop.
#!/bin/bash
# https://github.com/Ceryn/img
# Call with '-s' to target only a selection of the screen.
clientid='GETYOUROWNCLIENTID'
img=$(mktemp '/tmp/img-XXXXXX.png')
import $img >/dev/null 2>&1 || exit
res=$(curl -sH "Authorization: Client-ID $clientid" -F "image=@$img" "https://api.imgur.com/3/upload")
echo $res | grep -qo '"status":200' && link=$(echo $res | sed -e 's/.*"link":"\([^"]*\).*/\1/' -e 's/\\//g')
test -n "$link" && (printf "\a" && rm "$img") || echo "$res" > "$img.error"
echo $link >> ~/.imgur.log
xdg-open $link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment