1 |
10669cc7
|
Assos Assos
|
# BASH completion script for Drush.
|
2 |
|
|
#
|
3 |
|
|
# Place this in your /etc/bash_completion.d/ directory or source it from your
|
4 |
|
|
# ~/.bash_completion or ~/.bash_profile files. Alternatively, source
|
5 |
|
|
# examples/example.bashrc instead, as it will automatically find and source
|
6 |
|
|
# this file.
|
7 |
|
|
|
8 |
|
|
# Ensure drush is available.
|
9 |
|
|
which drush > /dev/null || alias drush &> /dev/null || return
|
10 |
|
|
|
11 |
|
|
__drush_ps1() {
|
12 |
|
|
f="${TMPDIR:-/tmp/}/drush-env/drush-drupal-site-$$"
|
13 |
|
|
if [ -f $f ]
|
14 |
|
|
then
|
15 |
|
|
__DRUPAL_SITE=$(cat "$f")
|
16 |
|
|
else
|
17 |
|
|
__DRUPAL_SITE="$DRUPAL_SITE"
|
18 |
|
|
fi
|
19 |
|
|
|
20 |
|
|
[[ -n "$__DRUPAL_SITE" ]] && printf "${1:- (%s)}" "$__DRUPAL_SITE"
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
# Completion function, uses the "drush complete" command to retrieve
|
24 |
|
|
# completions for a specific command line COMP_WORDS.
|
25 |
|
|
_drush_completion() {
|
26 |
|
|
# Set IFS to newline (locally), since we only use newline separators, and
|
27 |
|
|
# need to retain spaces (or not) after completions.
|
28 |
|
|
local IFS=$'\n'
|
29 |
|
|
# The '< /dev/null' is a work around for a bug in php libedit stdin handling.
|
30 |
|
|
# Note that libedit in place of libreadline in some distributions. See:
|
31 |
|
|
# https://bugs.launchpad.net/ubuntu/+source/php5/+bug/322214
|
32 |
|
|
COMPREPLY=( $(drush --early=includes/complete.inc "${COMP_WORDS[@]}" < /dev/null 2> /dev/null) )
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
# Register our completion function. We include common short aliases for Drush.
|
36 |
|
|
complete -o bashdefault -o default -o nospace -F _drush_completion d dr drush drush5 drush6 drush7 drush.php
|