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 drush
alias drcc='drush cc all' // clear all the caches
alias drup='drush up' // update core and contrib modules
alias drupdb='drush updb' // run update.php
alias dren='drush en' // enable a module/theme
alias drdis='drush dis' // disable a module/theme
alias drfl='drush fl' // list all features on the site
alias drflo='drush fl | grep Overridden' // list all overridden features
alias drfu='drush -y features-update' // update a feature - you must put the feature's name after this
alias drfua='drush -y features-update all' // update all feature
alias drfr='drush -y features-revert' // revert a feature - you must put the feature's name after this
alias drfra='drush -y features-revert all' // revert all features
alias 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?