September 13, 2013

If you are like me, you have a lot of Drush aliases in your life, aliases for local sites, sites on dev servers, sites at Pantheon, sites at Acquia, sites all over the place.

To get all of the aliases for your Pantheon sites, log into your Pantheon account and click the link in the top right corner of the "Your Sites" page to download.

Pantheon screenshot

To get these aliases at Acquia, click on the cloud link, click the "Drush and API" option on the left navigation and then the download button at the top of that page.

Acquia screenshot

If all of your sites are local or on your own server, I've done a little work on a script that can generate an alias file for you. It has some bugs and makes a lot of assumptions about how you organize things (pull requests welcome!), but it works for most Drupal sites that it finds.

Once you have dumped all of the alias files that you have collected in your ~/.drush folder and typed drush site-alias, you will probably be confronted with a long long list of aliases. These names are often something cryptic, usually a 4-letter abbreviation for the site or something equally difficult to remember.

The trick I use to keep this list manageable is to rename the generated files to include a pointer to the service. So sitename.aliases.drushrc.php becomes a.sitename.aliases.drushrc.php for Acquia sites, and pantheon.aliases.drushrc.php becomes p.aliases.drushrc.php.

Now, when I type drush site-alias, all of my aliases are prepended with an @a an @p an @local or an @dev. I like to keep my names short for less typing, but you can make them longer for readability.

I find that it is much easier to remember where a site is hosted than what it is called at that host. When I'm looking for an alias, I type drush sa | grep @p and I get spit back a shortened list of relevant aliases from a particular host.

Now that your alias list is more manageable, head over to the Drush documentation and dream up cool new ways to make your aliases even more powerful.