_fossil 692 B

1234567891011121314151617181920212223242526272829303132
  1. #compdef fossil
  2. function _fossil_get_command_list () {
  3. fossil help -a | grep -v "Usage|Common|This is"
  4. }
  5. function _fossil () {
  6. local context state state_descr line
  7. typeset -A opt_args
  8. _arguments \
  9. '1: :->command'\
  10. '2: :->subcommand'
  11. case $state in
  12. command)
  13. local _OUTPUT=$(fossil branch 2>&1 | grep "use --repo")
  14. if [[ -z "$_OUTPUT" ]]; then
  15. compadd "$(_fossil_get_command_list)"
  16. else
  17. compadd clone init import help version
  18. fi ;;
  19. subcommand)
  20. case "$words[2]" in
  21. help) compadd "$(_fossil_get_command_list)" ;;
  22. add) compadd "$(fossil extra)" ;;
  23. *) compcall -D ;;
  24. esac ;;
  25. esac
  26. }
  27. _fossil "$@"