Skip to content

Instantly share code, notes, and snippets.

@hiroshi
Created April 19, 2011 13:27
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 hiroshi/927683 to your computer and use it in GitHub Desktop.
Save hiroshi/927683 to your computer and use it in GitHub Desktop.
goo.gl Automator Service
#!/bin/sh
# 0. Requires Mac OS X 10.6 (Snow Leopard) or later
# 1. Open Automator.app
# 2. Choose "Service" template
# 3. Enter "shell" and drag & drop "Run Shell Script"
# 4. Check "Replaces selected text"
# 5. Ensure that Shell: "/bin/bash" and Pass input: "to stdin"
# 6. Paste ***ENTIRE THIS SCRIPT*** to the textarea
# 7. Save the service as "goo.gl" or what you like
url=$(cat /dev/stdin)
echo ${url} | pbcopy
curl -H "Content-Type: application/json" -d "{\"longUrl\": \"${url}\"}" https://www.googleapis.com/urlshortener/v1/url | /usr/bin/ruby -ryaml -e 'puts YAML.load(ARGF.read)["id"]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment