Skip to content

Instantly share code, notes, and snippets.

@dubgeiser
Created April 4, 2012 14:50
Show Gist options
  • Select an option

  • Save dubgeiser/2302110 to your computer and use it in GitHub Desktop.

Select an option

Save dubgeiser/2302110 to your computer and use it in GitHub Desktop.
Upload Mac OS X screenshot to imgur.
#!/bin/bash
#
# Upload a screenshot to imgur "on the fly":
# Let user select region, take screenshot
# Upload screenshot to imgur.com
# Print resulting url to image.
#
# @see http://api.imgur.com/examples
#
# API Key provided by Alan@imgur.com, replace with your own.
api_key="b3625162d3418ac51a9ee805b1840452"
url_api_upload="http://api.imgur.com/2/upload.xml"
fn_image="/tmp/screenshot-`date +%Y-%m-%d-%H-%M-%S`.png"
screencapture -ix $fn_image
response=`curl -s -F "image=@$fn_image" -F "key=$api_key" $url_api_upload`
echo $response | tail -1 | sed -E 's/.*<original>(.*)<\/original>.*/\1/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment