I have a drush command for installing a Drupal website with configuration in it. I do not want to type this command with all the configuration all the time because it is long so I would like to encapsulate the command as alias but I still want to pass additional arguments to the original command.

Specifically I need to pass at least the db url since that will always be different.

I was thinking something like this: drush install-mysite --db-url="..."

So basically any argument that is provided to my alias would override the defined argument defined in my alias.

From what I have read this could be done with drush aliases but I am not sure about the syntax and the arguments themselves. Another way is to create a new drush function but I think alias is simpler and I don't need any additional functionality.

This is for Drupal 8 so Drush 7 but I think it is not that relevant.

  • Now you need Drush 8 for Drupal 8. Commented Jul 14, 2015 at 17:54

1 Answer 1


The best way to provide default options to a Drush command, whether it is a core Drush command or a custom command you have written, is to place your default values into a drushrc.php file under a command-specific option.

For example, if you wanted the Drush site-install command to always name the site admin 'superuser', and you wanted to always install with the password 'secretsecret', then you could add the following definition:

$command_specific['site-install'] = array(
  'account-name' => 'superuser',
  'account-pass' => 'secretsecret',

If you later decided you wanted to use a different account name for a site you were installing, then you could just run drush site-install --account-name=su, and the option from your configuration file would be overridden.

If the only purpose of your install-mysite command was to select default values for site-install, then the above configuration is all that you will need. If you want to add additional code that does other things after the install, though, then you could go ahead and write your custom command, and place a $command_specific['install-mysite'] entry in your drushrc.php file to provide the default values for your command's options.

If you only want to make minor changes to the way the site-install command works, you might want to also consider providing a "policy file" that provides a hook that runs after the install command finishes. See policy.drush.inc for details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.