Skip to content
Browse files

Finish up qs script in bash (oauth version looks too tricky).

  • Loading branch information...
1 parent 0f69af6 commit 19cf12ba6f62410f79f93c173ea734e1e2d9f276 @cespare committed
Showing with 5 additions and 1 deletion.
  1. +5 −1 qs
View
6 qs
@@ -16,6 +16,7 @@ hash scrot 2>&- || fail "requires scrot (sudo apt-get install scrot)"
hash xclip 2>&- || fail "requires xclip (sudo apt-get install xclip)"
hash curl 2>&- || fail "requires curl (sudo apt-get install curl)"
hash xdg-open 2>&- || fail "requires xdg-open (sudo apt-get install xdg-utils)"
+hash ruby 2>&- || fail "requires ruby (sudo apt-get install ruby)"
[[ -z $IMGUR_API_KEY ]] && fail '$IMGUR_API_KEY needs to be set (to your Imgur developer API key).'
@@ -25,4 +26,7 @@ xdg-open $TEMP
read -p "Upload this screenshot to imgur? [yN] " -n 1
echo
[[ ! $REPLY =~ ^[Yy]$ ]] && exit 1
-curl -F "image=@$TEMP" -F "key=$IMGUR_API_KEY" http://api.imgur.com/2/upload.json
+url=$(curl -F "image=@$TEMP" -F "key=$IMGUR_API_KEY" http://api.imgur.com/2/upload.json | ruby -pe '$_.match /"original":"([^"]*)",/; $_ = $1.gsub("\\", "")')
+echo -n $url | xclip
+echo "Image uploaded to imgur (this url is in your clipboard as well):"
+echo $url

0 comments on commit 19cf12b

Please sign in to comment.
Something went wrong with that request. Please try again.