_brew 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #compdef brew
  2. #autoload
  3. # imported from the latest homebrew contributions
  4. _brew_all_formulae() {
  5. formulae=(`brew search`)
  6. }
  7. _brew_installed_formulae() {
  8. installed_formulae=(`brew list`)
  9. }
  10. local -a _1st_arguments
  11. _1st_arguments=(
  12. 'cat:display formula file for a formula'
  13. 'cleanup:uninstall unused and old versions of packages'
  14. 'create:create a new formula'
  15. 'deps:list dependencies and dependants of a formula'
  16. 'doctor:audits your installation for common issues'
  17. 'edit:edit a formula'
  18. 'home:visit the homepage of a formula or the brew project'
  19. 'info:information about a formula'
  20. 'install:install a formula'
  21. 'link:link a formula'
  22. 'list:list files in a formula or not-installed formulae'
  23. 'log:git commit log for a formula'
  24. 'outdated:list formulas for which a newer version is available'
  25. 'prune:remove dead links'
  26. 'remove:remove a formula'
  27. 'search:search for a formula (/regex/ or string)'
  28. 'unlink:unlink a formula'
  29. 'update:freshen up links'
  30. 'uses:show formulas which depend on a formula'
  31. )
  32. local expl
  33. local -a formula installed_formulae
  34. _arguments \
  35. '(-v --verbose)'{-v,--verbose}'[verbose]' \
  36. '(--version)--version[version information]' \
  37. '(--prefix)--prefix[where brew lives on this system]' \
  38. '(--cache)--cache[brew cache]' \
  39. '*:: :->subcmds' && return 0
  40. if (( CURRENT == 1 )); then
  41. _describe -t commands "brew subcommand" _1st_arguments
  42. return
  43. fi
  44. case "$words[1]" in
  45. list)
  46. _arguments \
  47. '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
  48. '1: :->forms' && return 0
  49. if [[ "$state" == forms ]]; then
  50. _brew_installed_formulae
  51. _requested installed_formulae expl 'installed formulae' compadd -a installed_formulae
  52. fi ;;
  53. install|home|log|info|uses|cat|deps)
  54. _brew_all_formulae
  55. _wanted formulae expl 'all formulae' compadd -a formulae ;;
  56. remove|edit|xo)
  57. _brew_installed_formulae
  58. _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
  59. esac