3 # BASH completion script for Drush.
5 # Place this in your /etc/bash_completion.d/ directory or source it from your
6 # ~/.bash_completion or ~/.bash_profile files. Alternatively, source
7 # examples/example.bashrc instead, as it will automatically find and source
10 # Ensure drush is available.
11 which drush > /dev/null || alias drush &> /dev/null || return
14 f="${TMPDIR:-/tmp/}/drush-env/drush-drupal-site-$$"
17 DRUPAL_SITE=$(cat "$f")
20 [[ -n "$DRUPAL_SITE" ]] && printf "${1:- (%s)}" "$DRUPAL_SITE"
23 # Completion function, uses the "drush complete" command to retrieve
24 # completions for a specific command line COMP_WORDS.
26 # Set IFS to newline (locally), since we only use newline separators, and
27 # need to retain spaces (or not) after completions.
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) )
35 # Register our completion function. We include common short aliases for Drush.
36 complete -o nospace -F _drush_completion d dr drush drush5 drush6 drush6 drush.php