1 # -*- mode: shell-script; mode: flyspell-prog; ispell-local-dictionary: "american" -*-
3 # Example bash aliases to improve your Drush experience with bash.
4 # Use `drush init` to copy this file to your home directory, rename and
5 # customize it to suit, and source it from your ~/.bashrc file.
7 # Creates aliases to common Drush commands that work in a global context:
10 # ddd - drush drupal-directory
11 # dl - drush pm-download
13 # sa - drush site-alias
14 # sa - drush site-alias --local-only (show local site aliases)
15 # st - drush core-status
16 # use - drush site-set
18 # Aliases for Drush commands that work on the current drupal site:
20 # cc - drush cache-clear
21 # cr - drush cache-rebuild
22 # cca - drush cache-clear all
23 # dis - drush pm-disable
24 # en - drush pm-enable
27 # rf - drush pm-refresh
28 # unin - drush pm-uninstall
29 # up - drush pm-update
30 # upc - drush pm-updatecode
31 # updb - drush updatedb
34 # Provides several common shell commands to work better with Drush:
36 # ddd @dev - print the path to the root directory of @dev
37 # cdd @dev - change the current working directory to @dev
38 # lsd @dev - ls root folder of @dev
39 # lsd %files - ls "files" directory of current site
40 # lsd @dev:%devel - ls devel module directory in @dev
41 # @dev st - drush @dev core-status
42 # dssh @live - ssh to the remote server @live points at
43 # gitd @live pull - run `git pull` on the drupal root of @live
45 # Drush site alias expansion is also done for the cpd command:
47 # cpd -R @site1:%files @site2:%files
49 # Note that the 'cpd' alias only works for local sites. Use
50 # `drush rsync` or gitd` to move files between remote sites.
52 # Aliases are also possible for the following standard
53 # commands. Uncomment their definitions below as desired.
61 # These standard commands behave exactly the same as they always
62 # do, unless a Drush site specification such as @dev or @live:%files
63 # is used in one of the arguments.
65 # Aliases for common Drush commands that work in a global context.
67 alias ddd='drush drupal-directory'
68 alias dl='drush pm-download'
69 alias ev='drush php-eval'
70 alias sa='drush site-alias'
71 alias lsa='drush site-alias --local-only'
72 alias st='drush core-status'
73 alias use='drush site-set'
75 # Aliases for Drush commands that work on the current drupal site
76 alias cc='drush cache-clear'
77 alias cr='drush cache-rebuild'
78 alias cca='drush cache-clear all'
79 alias dis='drush pm-disable'
80 alias en='drush pm-enable'
81 alias pmi='drush pm-info'
82 alias pml='drush pm-list'
83 alias rf='drush pm-refresh'
84 alias unin='drush pm-uninstall'
85 alias up='drush pm-update'
86 alias upc='drush pm-updatecode'
87 alias updb='drush updatedb'
88 alias q='drush sql-query'
90 # Overrides for standard shell commands. Uncomment to enable. Alias
91 # cd='cdd' if you want to be able to use cd @remote to ssh to a
100 # We extend the cd command to allow convenient
101 # shorthand notations, such as:
106 # You must use 'cddl' instead of 'cd' if you are not using
107 # the optional 'cd' alias from above.
108 # This is the "local-only" version of the function;
109 # see the cdd function, below, for an expanded implementation
110 # that will ssh to the remote server when a remote site
111 # specification is used.
117 # Use this function instead of 'cddl' if you have a very large number
118 # of alias files, and the 'cddl' function is getting too slow as a result.
119 # This function does not automatically set your prompt to the site that
120 # you 'cd' to, as 'cddl' does.
121 function fastcddl() {
126 elif [ "${s:0:1}" == "@" ] || [ "${s:0:1}" == "%" ]
128 d="$(drush drupal-directory $1 --local-only 2>/dev/null)"
134 t="$(drush site-alias $1 >/dev/null 2>/dev/null)"
137 echo "Cannot cd to remote site $s"
139 echo "Cannot cd to $s"
147 # Works just like the `cddl` shell alias above, with one additional
148 # feature: `cdd @remote-site` works like `ssh @remote-site`,
149 # whereas cd above will fail unless the site alias is local. If
150 # you prefer this behavior, you can add `alias cd='cdd'` to your .bashrc
156 elif [ "${s:0:1}" == "@" ] || [ "${s:0:1}" == "%" ]
158 d="$(drush drupal-directory $s 2>/dev/null)"
159 rh="$(drush sa ${s%%:*} --fields=remote-host --format=list)"
167 c="cd \"$d\" \; bash"
168 drush -s ${s%%:*} ssh --tty
169 drush ${s%%:*} ssh --tty
179 # Allow `git @site gitcommand` as a shortcut for `cd @site; git gitcommand`.
180 # Also works on remote sites, though.
183 if [ -n "$s" ] && [ ${s:0:1} == "@" ] || [ ${s:0:1} == "%" ]
185 d="$(drush drupal-directory $s 2>/dev/null)"
186 rh="$(drush sa ${s%%:*} --fields=remote-host --format=list)"
189 drush ${s%%:*} ssh "cd '$d' ; git ${@:2}"
191 echo cd "$d" \; git "${@:2}"
202 # Get a directory listing on @site or @site:%files, etc, for local or remote sites.
207 if [ ${a:0:1} == "@" ] || [ ${a:0:1} == "%" ]
209 p[${#p[@]}]="$(drush drupal-directory $a 2>/dev/null)"
210 if [ ${a:0:1} == "@" ]
212 rh="$(drush sa ${a%:*} --fields=remote-host --format=list)"
225 drush $r ssh 'ls "${p[@]}"'
231 # Copy files from or to @site or @site:%files, etc; local sites only.
235 if [ ${a:0:1} == "@" ] || [ ${a:0:1} == "%" ]
237 p[${#p[@]}]="$(drush drupal-directory $a --local-only 2>/dev/null)"
246 # This alias allows `dssh @site` to work like `drush @site ssh`.
247 # Ssh commands, such as `dssh @site ls /tmp`, are also supported.
250 if [ ${d:0:1} == "@" ]
252 drush "$d" ssh "${@:2}"
258 # Drush checks the current PHP version to ensure compatibility, and fails with
259 # an error if less than the supported minimum (currently 5.4.5). If you would
260 # like to try to run Drush on a lower version of PHP, you can un-comment the
261 # line below to skip this check. Note, however, that this is un-supported.
263 # DRUSH_NO_MIN_PHP=TRUE