How to create Drush Aliases (shortcuts) in bash - make your life even easier
I'm lazy. So I create shortcuts. You should be like me!
When site building in Drupal, I am constantly using the drush si (site install) command to rebuild the site and check that my new feature is working correctly. Whilst this is a great way to get the site re-installed in super-quick time, it has a built in security feature of creating a user called admin (fine by me) and a new password for this user (which I then change to something simple like "admin" - just for development purposes). This is quite simple:
drush user-password admin --password="admin"
When I'm given a new project to work on, the first thing I do with my local instance is set the admin password to "admin".
To speed things up, I decided to write a drush alias to make these two use-cases easier to manage (yes, I know, first world problems!). And then I thought, why not share this and some of my other aliases. So, here goes (with comments):
alias dr='drush' // general alias for drushalias drcc='drush cc all' // clear all the cachesalias drup='drush up' // update core and contrib modulesalias drupdb='drush updb' // run update.phpalias dren='drush en' // enable a module/themealias drdis='drush dis' // disable a module/themealias drfl='drush fl' // list all features on the sitealias drflo='drush fl | grep Overridden' // list all overridden featuresalias drfu='drush -y features-update' // update a feature - you must put the feature's name after thisalias drfua='drush -y features-update all' // update all featurealias drfr='drush -y features-revert' // revert a feature - you must put the feature's name after thisalias drfra='drush -y features-revert all' // revert all featuresalias drpad='drush user-password admin --password="admin"' // change password for user admin to admin
Note: to get these working, I put them in my bash_profile file. Every time I add a new one, I run source ~/.bash_profile to reload the file and make the alias available to drush.
What aliases do you use?
Join the "Something nice ..." newsletter
The full title is "Something nice, something quirky, something else".
I send an email once a week with something nice, something quirky, and something else that I think is interesting (all with a web development theme, of course).