Created
December 31, 2017 21:04
-
-
Save sofar/113c9be7256a37ef1d3e2c328ea5b322 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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