Fix test failure in 'Drush dl needs to put files in /modules or /themes, not /sites...
[project/drush.git] / drush.complete.sh
1 #!/bin/bash
2
3 # BASH completion script for Drush.
4 #
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
8 # this file.
9
10 # Ensure drush is available.
11 which drush > /dev/null || alias drush &> /dev/null || return
12
13 __drush_ps1() {
14   f="${TMPDIR:-/tmp/}/drush-env/drush-drupal-site-$$"
15   if [ -f $f ]
16   then
17     DRUPAL_SITE=$(cat "$f")
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 nospace -F _drush_completion d dr drush drush5 drush6 drush6 drush.php