Skip to content

Instantly share code, notes, and snippets.

@magamig
Created November 27, 2015 16:00
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 magamig/ba058a0ff02928d8ebaf to your computer and use it in GitHub Desktop.
Save magamig/ba058a0ff02928d8ebaf to your computer and use it in GitHub Desktop.
Script to shorten URLs (through bit.ly) (from: http://www.aproposmac.com/2011/06/shorten-url-on-bitly-using-curl.html and j.erik comment)
#!/bin/bash
#
# Change 'YOURLOGIN' and 'YOURAPIKEY' before using!
#
# Instructions:
# 1. Copy the url you wish to shorten to the clipboard.
# 2. Run the script, the shorten url will be in your
# clipboard now and all you have to do is paste it
# where you want it.
#
url=$(pbpaste)
curl -s "http://api.bitly.com/v3/shorten?login=YOURLOGIN&apiKey=YOURAPIKEY&longUrl=$url&format=txt" | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment