/bash_completion_lib/complete/complete

http://github.com/brinkman83/bashrc · #! · 55 lines · 47 code · 8 blank · 0 comment · 0 complexity · d35c01bd5219eabffeb6dce439f46ef7 MD5 · raw file

  1. comp_include _get_cword
  2. _complete()
  3. {
  4. local cur prev options
  5. COMPREPLY=()
  6. cur=`_get_cword`
  7. prev=${COMP_WORDS[COMP_CWORD-1]}
  8. case $prev in
  9. -o)
  10. options="default dirnames filenames"
  11. [ -n "$bash205b" ] && options="$options nospace"
  12. [ -n "$bash3" ] && options="$options bashdefault plusdirs"
  13. COMPREPLY=( $( compgen -W "$options" -- $cur ) )
  14. return 0
  15. ;;
  16. -A)
  17. COMPREPLY=( $( compgen -W 'alias arrayvar binding \
  18. builtin command directory disabled enabled \
  19. export file function group helptopic hostname \
  20. job keyword running service setopt shopt \
  21. signal stopped user variable' -- $cur ) )
  22. return 0
  23. ;;
  24. -C)
  25. COMPREPLY=( $( compgen -A command -- $cur ) )
  26. return 0
  27. ;;
  28. -F)
  29. COMPREPLY=( $( compgen -A function -- $cur ) )
  30. return 0
  31. ;;
  32. -@(p|r))
  33. COMPREPLY=( $( complete -p | sed -e 's|.* ||' | \
  34. grep "^$cur" ) )
  35. return 0
  36. ;;
  37. esac
  38. if [[ "$cur" == -* ]]; then
  39. # relevant options completion
  40. options="-a -b -c -d -e -f -g -j -k -s -v -u -A -G -W -P -S -X -F -C"
  41. [ -n "$bash205" ] && options="$options -o"
  42. COMPREPLY=( $( compgen -W "$options" -- $cur ) )
  43. else
  44. COMPREPLY=( $( compgen -A command -- $cur ) )
  45. fi
  46. }
  47. _complete