Security update for Core, with self-updated composer
[yaffs-website] / vendor / drush / drush / examples / example.bashrc
1 # -*- mode: shell-script; mode: flyspell-prog; ispell-local-dictionary: "american" -*-
2 #
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.
6 #
7 # Creates aliases to common Drush commands that work in a global context:
8 #
9 #       dr               - drush
10 #       ddd              - drush drupal-directory
11 #       dl               - drush pm-download
12 #       ev               - drush php-eval
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
17 #
18 # Aliases for Drush commands that work on the current drupal site:
19 #
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
25 #       i                - drush pm-info
26 #       pml              - drush pm-list
27 #       rf               - drush pm-refresh
28 #       unin             - drush pm-uninstall
29 #       up               - drush pm-update
30 #       upc              - drush pm-updatecode
31 #       updb             - drush updatedb
32 #       q                - drush sql-query
33 #
34 # Provides several common shell commands to work better with Drush:
35 #
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
44 #
45 # Drush site alias expansion is also done for the cpd command:
46 #
47 #       cpd -R @site1:%files @site2:%files
48 #
49 # Note that the 'cpd' alias only works for local sites.  Use
50 # `drush rsync` or gitd` to move files between remote sites.
51 #
52 # Aliases are also possible for the following standard
53 # commands. Uncomment their definitions below as desired.
54 #
55 #       cd                - cddl [*]
56 #       ls                - lsd
57 #       cp                - cpd
58 #       ssh               - dssh
59 #       git               - gitd
60 #
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.
64
65 # Aliases for common Drush commands that work in a global context.
66 alias dr='drush'
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'
74
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'
89
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
92 # remote site.
93
94 # alias cd='cddl'
95 # alias ls='lsd'
96 # alias cp='cpd'
97 # alias ssh='dssh'
98 # alias git='gitd'
99
100 # We extend the cd command to allow convenient
101 # shorthand notations, such as:
102 #   cd @site1
103 #   cd %modules
104 #   cd %devel
105 #   cd @site2:%files
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.
112 function cddl() {
113   fastcddl "$1"
114   use @self
115 }
116
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() {
122   s="$1"
123   if [ -z "$s" ]
124   then
125     builtin cd
126   elif [ "${s:0:1}" == "@" ] || [ "${s:0:1}" == "%" ]
127   then
128     d="$(drush drupal-directory $1 --local-only 2>/dev/null)"
129     if [ $? == 0 ]
130     then
131       echo "cd $d";
132       builtin cd "$d";
133     else
134       t="$(drush site-alias $1 >/dev/null 2>/dev/null)"
135       if [ $? == 0 ]
136       then
137         echo "Cannot cd to remote site $s"
138       else
139         echo "Cannot cd to $s"
140       fi
141     fi
142   else
143     builtin cd "$s";
144   fi
145 }
146
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
151 function cdd() {
152   s="$1"
153   if [ -z "$s" ]
154   then
155     builtin cd
156   elif [ "${s:0:1}" == "@" ] || [ "${s:0:1}" == "%" ]
157   then
158     d="$(drush drupal-directory $s 2>/dev/null)"
159     rh="$(drush sa ${s%%:*} --fields=remote-host --format=list)"
160     if [ -z "$rh" ]
161     then
162       echo "cd $d"
163       builtin cd "$d"
164     else
165       if [ -n "$d" ]
166       then
167         c="cd \"$d\" \; bash"
168         drush -s ${s%%:*} ssh --tty
169         drush ${s%%:*} ssh --tty
170       else
171         drush ssh ${s%%:*}
172       fi
173     fi
174   else
175     builtin cd "$s"
176   fi
177 }
178
179 # Allow `git @site gitcommand` as a shortcut for `cd @site; git gitcommand`.
180 # Also works on remote sites, though.
181 function gitd() {
182   s="$1"
183   if [ -n "$s" ] && [ ${s:0:1} == "@" ] || [ ${s:0:1} == "%" ]
184   then
185     d="$(drush drupal-directory $s 2>/dev/null)"
186     rh="$(drush sa ${s%%:*} --fields=remote-host --format=list)"
187     if [ -n "$rh" ]
188     then
189       drush ${s%%:*} ssh "cd '$d' ; git ${@:2}"
190     else
191       echo cd "$d" \; git "${@:2}"
192       (
193         cd "$d"
194         "git" "${@:2}"
195       )
196     fi
197   else
198     "git" "$@"
199   fi
200 }
201
202 # Get a directory listing on @site or @site:%files, etc, for local or remote sites.
203 function lsd() {
204   p=()
205   r=
206   for a in "$@" ; do
207     if [ ${a:0:1} == "@" ] || [ ${a:0:1} == "%" ]
208     then
209       p[${#p[@]}]="$(drush drupal-directory $a 2>/dev/null)"
210       if [ ${a:0:1} == "@" ]
211       then
212         rh="$(drush sa ${a%:*} --fields=remote-host --format=list)"
213         if [ -n "$rh" ]
214         then
215           r=${a%:*}
216         fi
217       fi
218     elif [ -n "$a" ]
219     then
220       p[${#p[@]}]="$a"
221     fi
222   done
223   if [ -n "$r" ]
224   then
225     drush $r ssh 'ls "${p[@]}"'
226   else
227     "ls" "${p[@]}"
228   fi
229 }
230
231 # Copy files from or to @site or @site:%files, etc; local sites only.
232 function cpd() {
233   p=()
234   for a in "$@" ; do
235     if [ ${a:0:1} == "@" ] || [ ${a:0:1} == "%" ]
236     then
237       p[${#p[@]}]="$(drush drupal-directory $a --local-only 2>/dev/null)"
238     elif [ -n "$a" ]
239     then
240       p[${#p[@]}]="$a"
241     fi
242   done
243   "cp" "${p[@]}"
244 }
245
246 # This alias allows `dssh @site` to work like `drush @site ssh`.
247 # Ssh commands, such as `dssh @site ls /tmp`, are also supported.
248 function dssh() {
249   d="$1"
250   if [ ${d:0:1} == "@" ]
251   then
252     drush "$d" ssh "${@:2}"
253   else
254     "ssh" "$@"
255   fi
256 }
257
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.
262
263 # DRUSH_NO_MIN_PHP=TRUE