This custom drush command will make you a better Drupal developer

When faced with a repetitive development task I like to throw a bash script at the problem. And nothing elevates the power of a bash script in Drupal development more than using Drush.

Drush is a command line tool for managing a Drupal site. It’s a developers best friend. But the real power of Drush is in writing your own custom Drush commands.

Whenever I start a new Drupal project I drop in a special Drush command I wrote to quickly make a local installation developer friendly. I call it drush golocal. This command enables developer friendly modules like Devel, Stage File Proxy, and Views UI, enables email rerouting so your local install doesn’t send emails to users, disables a bunch of internal Drupal caching, and sets some helpful permissions.

I place this code in a custom module in a special include file where drush looks for commands: EXAMPLE.drush.inc.

As development continues (and after launch for support), this is the perfect place to add site-specific changes that relate only to that project (such as switching to development instances of third-party systems to which your site connects).

Bonus Points!

Now that you have a handy way to put a site into development mode in your local installation, consider integrating this script into your dev/stage/production workflow. If you use a platform like Acquia Cloud that provides deployment hooks, you can have this routine run every time you copy the production database to the dev server automagically.

You can even take it a step further and write a bash script that downloads a copy of the production database, imports it into your local install, and then runs this command. Suddenly you can update your local environment from production and have it ready for development with one simple command.