Skip to content

Instantly share code, notes, and snippets.

@BillKeenan
Created March 6, 2014 20:45
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 BillKeenan/9399284 to your computer and use it in GitHub Desktop.
Save BillKeenan/9399284 to your computer and use it in GitHub Desktop.
Google Shortener for TextExpander
--- This will take a url on your clipboard, and use google to shorten it
--- create a new text expander item, set to applescript and paste this in.
set the ClipURL to (the clipboard as string)
ignoring case
if ((characters 1 through 4 of ClipURL as string) is not "http") then
return "Malformed URL."
else
set curlCMD to ¬
"curl -H 'Content-Type:application/json' -d '{\"longUrl\": \"" & ClipURL & "\" }' https://www.googleapis.com/urlshortener/v1/url"
-- Run the script and get the result:
set postWeather to "grep -o '[^\"]*goo.gl[^\"]*'"
set forecast to do shell script curlCMD & " | " & postWeather
return forecast
end if
end ignoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment