Skip to content

Instantly share code, notes, and snippets.

@brennanMKE
Last active November 24, 2020 18:10
Show Gist options
  • Save brennanMKE/53cfd0d03ec3b89808af to your computer and use it in GitHub Desktop.
Save brennanMKE/53cfd0d03ec3b89808af to your computer and use it in GitHub Desktop.
Bitly Command-line Shortener
#!/bin/sh
# Note: Be sure to set BITLY_LOGIN and BITLY_APIKEY in .bash_profile
# .bash_profile
#
# export BITLY_LOGIN=REPLACE_WITH_LOGIN
# export BITLY_APIKEY=REPLACE_WITH_KEY
#
# Then run "source ~/.bash_profile" to update your current shell.
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <URL>"
else
URI=$1
REQUEST="https://api-ssl.bit.ly/v3/shorten?login=$BITLY_LOGIN&apiKey=$BITLY_APIKEY&format=txt&uri=$URI"
curl $REQUEST
echo
fi
@umeditor
Copy link

Thanks for the script. I made one small change to use ssl when making the request. See code at https://gist.github.com/umeditor/e83b8be30e0432978f6b.

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