/bash_completion_lib/complete/chkconfig

http://github.com/brinkman83/bashrc · #! · 35 lines · 28 code · 7 blank · 0 comment · 0 complexity · 44fbc7c46537ec48ead04b6b9ff7447f MD5 · raw file

  1. # chkconfig(8) completion
  2. comp_include _get_cword _services
  3. _chkconfig()
  4. {
  5. local cur prev
  6. COMPREPLY=()
  7. cur=`_get_cword`
  8. prev=${COMP_WORDS[COMP_CWORD-1]}
  9. case "$prev" in
  10. @([1-6]|--@(list|add|del)))
  11. _services
  12. return 0
  13. ;;
  14. --level)
  15. COMPREPLY=( $( compgen -W '1 2 3 4 5 6' -- $cur ) )
  16. return 0
  17. ;;
  18. esac
  19. if [[ "$cur" == -* ]]; then
  20. COMPREPLY=( $( compgen -W '--list --add --del --level' -- $cur ) )
  21. else
  22. if [ $COMP_CWORD -eq 2 -o $COMP_CWORD -eq 4 ]; then
  23. COMPREPLY=( $( compgen -W 'on off reset' -- $cur ) )
  24. else
  25. _services
  26. fi
  27. fi
  28. } # chkconfig()