Created
June 28, 2013 20:10
-
-
Save zhuravel/5887703 to your computer and use it in GitHub Desktop.
Shorten URLs from command line
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
#!/usr/bin/env sh | |
# Create a git.io short URL | |
function gitio() { | |
if [ $# -eq 2 ]; then | |
curl -i http://git.io/ -F "url=${1}" -F "code=${2}" | |
elif [ ! -z $1 ]; then | |
curl -i http://git.io/ -F "url=${1}" | |
else | |
echo 'Usage: gitio http://github.com/link [custom-name]' | |
return 1 | |
fi | |
} | |
# Create an l.md short URL | |
function lmd() { | |
if [ $# -eq 2 ]; then | |
curl http://l.md/api/post -F "url=${1}" -F "custom=${2}" | python -mjson.tool | |
elif [ ! -z $1 ]; then | |
curl http://l.md/api/post -F "url=${1}" | python -mjson.tool | |
else | |
echo 'Usage: lmd http://example.com/link [custom-name]' | |
return 1 | |
fi | |
} | |
# Expand shortened URL | |
function longurl() { | |
curl -sIL $1 2>&1 | awk '/^Location/ {print $2}' | tail -n1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
seems gitio no longer works?