Created
April 19, 2011 13:27
-
-
Save hiroshi/927683 to your computer and use it in GitHub Desktop.
goo.gl Automator Service
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/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