Automate Local Development with BASH

bash logo

I can’t afford to be inefficient at Efficiency of Movement. I am a one-man show and any wasted movement is wasted money. I started to notice that I was repeating myself more than I should have been. It was high time to automate my process even more.

Developing Locally

When I start a new project, like many other developers, I’m sure, I go out to download a fresh copy of WordPress and set it up manually. It is a fairly straight forward process and the development team at WordPress has done an excellent job at making it easy. They even coined the process the famous 5-Minute Installation. They’ve done their part to make it easy, the rest is up to the professional developer. This is especially true if the developer is making multiple websites a week or month. The amount of time spent on opening up applications, alone, is cringe-worthy. Much less the inconsistencies of file names, user names and profiles, installing plugins, activating, blah, blah, blah. Hours later…

BASH to the Rescue

imgresBASH scripts are not complex. At their foundation, they are a series of steps performed by the machine set in particular order. You write the script and tell the machine what to do and the machine does it. It is automation at it’s purest. I had used BASH before and knew that was powerful but combined with tools that others have created specifically for WordPress this script is now a powerhouse. I estimate that it saves 1.5 hours of development time. I wish I can only image the amount of frustration that it saves by creating with consistent naming convents and consistent file locations.

Save Time

My estimation comes from the fact that the fastest that WordPress can be installed is 5 minutes. I don’t install WordPress, I make WordPress websites and that takes considerably more time to set up. I have to create a database locally, that if done right can be used on a live server. I have to remove cruft that I don’t need like plugins and themes that come preinstalled. I have to add users and their roles to to the site. I have to add pages to the site. This script now takes care of all of that. Basically, those items are nothing more than a series of commands performed in a specific order.

I also have to add things to each site I start. I have to add my starter theme and my plugins. I have to activate some and deactivate others. Again, a script is the perfect tool to make this an automatic process.

Automate my Local Development

mamp-pro-logo-bigI don’t want to place the code in this post because it will likely change as time goes on. But, here is a link to my script, but I’ll walk you through it here, too. First I want consistency in names and locations. I prompt for the web site’s name. The user can use regular English words and spaces. The name of the web site is then used to create the rest of the variables inside of the script, such as database name, user names, and file locations. See, consistant.

I install WordPress and delete all the themes I don’t want. Then I clone into my own fork of Ole Frederick‘s fantastic starter theme, FoundationPress. I have made my own customizations that I want but that the community may not. My BASH brings down the files, runs the grunt tasks, and then opens up a browser window that is ready for my login information.


Fork my script and add your own customizations. Think about what keystrokes you are performing repeatedly. Can those keystrokes be performed by a machine? If so, then you should really get a script to do it for you. That way you can get back to solving the more interesting problems of web development.