Last active
November 24, 2020 18:10
-
-
Save brennanMKE/53cfd0d03ec3b89808af to your computer and use it in GitHub Desktop.
Bitly Command-line Shortener
This file contains hidden or 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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.