Skip to content

Instantly share code, notes, and snippets.

@tofias
Last active January 2, 2016 04:39
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 tofias/8252138 to your computer and use it in GitHub Desktop.
Save tofias/8252138 to your computer and use it in GitHub Desktop.
Get the Long URL for a Short URL
-- Get the Long URL for a Short URL
-- https://gist.github.com/tofias/8252138
set theClipboard to the clipboard as string
set myScript to "curl -sIL " & theClipboard & " | grep ^[lL]ocation | awk 'END{print}' | tr '[:upper:]' '[:lower:]' | tr -d '[[:space:]]' | sed s/'location:'// | tr -d '\n' | pbcopy"
do shell script myScript
set theClipboard to the clipboard as string
display dialog theClipboard with title "Long URL Ready to Paste" giving up after 5
-- TEST URL SHORT: http://t.co/9acY1bnnFg
-- SHOULD MAKE LONG URL: http://mosx.tumblr.com/post/72095032814/an-official-statement-on-the-future-of-mac-os-x#_=_
-- Inspired by http://mosx.tumblr.com/post/72105863417/get-every-redirect-of-a-short-url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment