Skip to content

Instantly share code, notes, and snippets.

@zhuravel
Created June 28, 2013 20:10
Show Gist options
  • Save zhuravel/5887703 to your computer and use it in GitHub Desktop.
Save zhuravel/5887703 to your computer and use it in GitHub Desktop.
Shorten URLs from command line
#!/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
}
@dragonxlwang
Copy link

seems gitio no longer works?

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