/bash_completion_lib/complete -o default/configure

http://github.com/brinkman83/bashrc · #! · 25 lines · 17 code · 8 blank · 0 comment · 0 complexity · f10ae11ef9994d4c3332581b8cdd85c8 MD5 · raw file

  1. comp_include _get_cword
  2. _configure_func()
  3. {
  4. local cur
  5. COMPREPLY=()
  6. cur=`_get_cword`
  7. # if $COMP_CONFIGURE_HINTS is not null, then completions of the form
  8. # --option=SETTING will include 'SETTING' as a contextual hint
  9. [[ "$cur" != -* ]] && return 0
  10. if [ -n "$COMP_CONFIGURE_HINTS" ]; then
  11. COMPREPLY=( $( $1 --help | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' | grep ^$cur ) )
  12. else
  13. COMPREPLY=( $( $1 --help | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,=].*//g' | grep ^$cur ) )
  14. fi
  15. } # _configure_func()
  16. comp_install -F _configure_func # Make completion persistent for subsequent invocations
  17. _configure_func # Generate completions for first invocation