A demo of how github can be made into a url shortener
Made for CMU GPI to help students learn git.
- Fork this repo
- Clone your forked repo. If you have ssh setup:
git clone [email protected]:[your github username]/gpi-url-shortener.git
Everyone else:
git clone https://github.com/[your github username]/gpi-url-shortener.git
- Rename the
example_github_config.py
togithub_config.py
, add your github username or custom github url in the file, and put the absolute path to your repo. Remember that when inside the repopwd
can give you the current directory's absolute path. - Make sure that you have ssh keys setup for your github. If you are not sure how to do this, you can follow this tutorial.
- Add to your
.bashrc
,.bash_profle
,.zshrc
, etc. the following:
shortenurl(){
current_dir=$(pwd)
cd /ABSOLUTE/PATH/TO/gpi-url-shortener/
python3 url_shortener.py
cd $current_dir
}
Don't forget to re-source
your rc
file!!
- In the repository settings turn on ghpages from the master branch
- You're all set!! Simply from terminal run:
shortenurl
And you should be walked through the process of shortening a url.
You should see something like this:
what url do you want to shorten?
url to be shortened: http(s)://thebomb.com.net.gov
shorten to https://[your github id].github.io/gpi-url-shortener/this_is_super_short
doing some stuff....
url has been shortened to: https://[your github id].github.io/gpi-url-shortener/this_is_super_short/
it might take ~5 mins for the link to become active
- If you have a custom domain you want to use with your url shortener, you can set it up for the github repo by following the instructions here.
Have fun and let us know if you have any questions on piazza!!!
Don't forget to hit the quan and yell YEAAAAAHHHH DONNER 👌 👌 👌 👌