Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Serve the current directory with MAMP from the command line
function mamp() {
# Default location of the apache conf file for MAMP
# Fish existing doc root out of conf file
LINE=$(cat $CONF_FILE | grep "^DocumentRoot")
QUOTED_STRING=${LINE/DocumentRoot /}
# Set new doc root to current directory
# Replace doc root strings in conf file
sed -i.bak -e "s|${OLD_DOC_ROOT}|${NEW_DOC_ROOT}|g" $CONF_FILE
# Restart server
sudo /Applications/MAMP/Library/bin/apachectl -k restart && sleep 2 && open "http://localhost:8888/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment