Skip to content

Instantly share code, notes, and snippets.

@chmouel
Created January 3, 2011 20:23
Show Gist options
  • Save chmouel/763907 to your computer and use it in GitHub Desktop.
Save chmouel/763907 to your computer and use it in GitHub Desktop.
Shorten URL and copy to clipboard for MacOSX
#!/bin/bash
CURRENT_SEL=$(pbpaste)
if [[ -n $1 ]];then
URL=$1
fi
if [[ -z $URL ]];then
if [[ ${CURRENT_SEL} == http://* ]];then
URL=${CURRENT_SEL}
else
echo "You need to specify an argument URL to shorten."
exit 1
fi
fi
[[ -z $URL ]] && { echo "No URL specified"; exit 1 ;}
SURL=$(curl -s http://is.gd/api.php\?longurl\=$URL)
echo -n $SURL|pbcopy
echo $SURL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment