summaryrefslogtreecommitdiffstats
path: root/docs/shellaliases.html
blob: 9f36e2e681861363e24cc1f2c56547cd7735da33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<h1>Drush Shell Aliases</h1>

A Drush shell alias is a shortcut to any Drush command or
any shell command.  Drush shell aliases are very similar
to git aliases.
<p>
  See: https://git.wiki.kernel.org/index.php/Aliases#Advanced
<p>
A shell alias is defined in a Drush configuration file
called drushrc.php.  See `drush topic docs-configuration`.
There are two kinds of shell aliases:  an alias whose value
begins with a '!' will execute the rest of the line as
bash commands.  Aliases that do not start with a '!' will
be interpreted as Drush commands.

<h3>Example:</h3>
<pre>
    $options['shell-aliases']['pull'] = '!git pull';
    $options['shell-aliases']['noncore'] = 'pm-list --no-core';
</pre>
With the above two aliases defined, `drush pull` will then be
equivalent to `git pull`, and `drush noncore` will be equivalent
to `drush pm-list --no-core`.

<h2>Shell Alias Replacements</h2>

Shell aliases are even more powerful when combined with shell alias
replacements and site aliases.  Shell alias replacements take the
form of {{sitealias-item}} or {{%pathalias-item}}, and also the
special {{@target}}, which is replaced with the name of the site alias
used, or '@none' if none was used.
<p>
For example, given the following site alias:
<pre>
     $aliases['dev'] = array (
       'root' => '/path/to/drupal',
       'uri' => 'mysite.org',
       '#live' => '@acme.live',
     );
</pre>
The alias below can be used for all your projects to fetch the database
and files from the client's live site via `drush @dev pull-data`.
Note that these aliases assume that the alias used defines an item named
'#live' (as shown in the above alias).

<h3>Shell aliases using replacements:</h3>
<pre>
    $options['shell-aliases']['pull-data'] = '!drush sql-sync {{#live}} {{@target}} && drush rsync {{#live}}:%files {{@target}}:%files';
</pre>
If the user does not use these shell aliases with any site alias, then
an error will be returned and the script will not run.

These aliases with replacements can be used to quickly run combinations of drush sql-sync
and rsync commands on the "standard" source or target site, reducing the risk of
typos that might send information in the wrong direction or to the wrong site.