MAMP Pro /etc/hosts file problems – Simplified

Lately I have been using a lot of host aliases for testing sites locally using my MAMP pro install. Adding local sites that answer to their actual site names is amazing for a development environment, especially if you find yourself testing javascript based apis that require oauth. Like the facebook or twitter apis.

MAMP Pro does have a problem however with not always turning off the entries in the /etc/hosts files when you stop the servers, so you have problems accessing the real site. Fixing this requires opening the hosts file manually and commenting or uncommenting the desired entries. A tedious pain.

So I decided to write a quick shell script that would allow me to reset the hosts file with a quick terminal command. See the one line install command and usage below.

Shell script for cleaning/resetting /etc/hosts files messed up by MAMP Pro — Gist.