Skip to content

Instantly share code, notes, and snippets.

@John07
Last active May 21, 2019 15:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save John07/4409401 to your computer and use it in GitHub Desktop.
Save John07/4409401 to your computer and use it in GitHub Desktop.
Tiny shell script for use with Textexpander to take a (Twitter) short URL and resolve it to the full URL Add it to Textexpander as a shell script, copy the shortened URL, type your Textexpander command and then the full URL will be pasted in
#!/bin/bash
URL=$(pbpaste)
curl "$URL" --insecure --write-out %{redirect_url}
@John07
Copy link
Author

John07 commented Dec 29, 2012

If you want it to work for bit.ly URLs too, change line 3 to

curl "$URL" --head --insecure | grep "Location\:" | sed 's/Location\: //g' | tr -d '\n' | tr -d '\r'

@John07
Copy link
Author

John07 commented Jan 18, 2013

Brett Terpstra has an even more elegant script here: http://brettterpstra.com/2010/08/14/is-your-url-too-short-try-our-system-free/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment