My first foray into Github
Sunday, Jun 19, 2011
I just posted my first project on Github yesterday. Calling it a “project” is a bit of a stretch, actually. A few weeks ago I was getting a little bit annoyed about the way all my development projects were organized. I use MAMP for local development, so I had a folder at ~/Sites (my root Directory for MAMP) with a bunch of subfolders in it for all the sites in various stages. Obviously this isn’t ideal, since it then requires adjusting quite a few settings once the sites go live.
So while I was trying to figure out a way that would allow me to organize my projects independently of what MAMP requires, I came across an article about using Virtual Hosts in MAMP. That essentially solved my problem, so that now I can put the root folder for each project wherever I want and just use *.local in my browser.
Of course at that point I start thinking that, since this is something I’ll likely be using pretty often, I should probably find a way to automate it. You know what that means? That’s right, Shell Scripting! I probably haven’t even tried to touch a shell script in at least 10 years, so this one took me a few hours. It could definitely use some more love, but since it’s already working for me, I may not touch it much, for fear that it will blow up. Right now it takes the domain name (without the .local part) and the file path to the root directory of the site, it’ll back up the /etc/hosts and the MAMP httpd.conf files first before writing to them, and make the necessary additions.
I figured I’d put it up on Github just in case someone else may find it useful. Of course YMMV, since you’ll need to modify a few parts to run on your own system. You’ll also need to use sudo, since root access is required to make changes to /etc/hosts/. I saved it into /usr/local/bin because that just seemed the simplest way to go. Enjoy, suggest improvements, and please let me know if it works for you.