drush.complete.sh

  1. 8.0.x drush.complete.sh
  2. 6.x drush.complete.sh
  3. 7.x drush.complete.sh
  4. 5.x drush.complete.sh
  5. master drush.complete.sh
#!/bin/bash

# BASH completion script for Drush.
#
# Place this in your /etc/bash_completion.d/ directory or source it from your
# ~/.bash_completion or ~/.bash_profile files.  Alternatively, source
# examples/example.bashrc instead, as it will automatically find and source
# this file.

# Ensure drush is available.
which drush > /dev/null || alias drush &> /dev/null || return

__drush_ps1() {
  f="${TMPDIR:-/tmp/}/drush-env/drush-drupal-site-$$"
  if [ -f $f ]
  then
    DRUPAL_SITE=$(cat "$f")
  fi

  [[ -n "$DRUPAL_SITE" ]] && printf "${1:- (%s)}" "$DRUPAL_SITE"
}

# Completion function, uses the "drush complete" command to retrieve
# completions for a specific command line COMP_WORDS.
_drush_completion() {
  # Set IFS to newline (locally), since we only use newline separators, and
  # need to retain spaces (or not) after completions.
  local IFS=$'\n'
  # The '< /dev/null' is a work around for a bug in php libedit stdin handling.
  # Note that libedit in place of libreadline in some distributions. See:
  # https://bugs.launchpad.net/ubuntu/+source/php5/+bug/322214
  COMPREPLY=( $(drush --early=includes/complete.inc "${COMP_WORDS[@]}" < /dev/null) )
}

# Register our completion function. We include common short aliases for Drush.
complete -o nospace -F _drush_completion d dr drush drush5 drush6 drush6 drush.php

File

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