_brew 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. 'upgrade:upgrade outdated formulae'
  31. 'uses:show formulas which depend on a formula'
  32. )
  33. local expl
  34. local -a formula installed_formulae
  35. _arguments \
  36. '(-v --verbose)'{-v,--verbose}'[verbose]' \
  37. '(--version)--version[version information]' \
  38. '(--prefix)--prefix[where brew lives on this system]' \
  39. '(--cache)--cache[brew cache]' \
  40. '*:: :->subcmds' && return 0
  41. if (( CURRENT == 1 )); then
  42. _describe -t commands "brew subcommand" _1st_arguments
  43. return
  44. fi
  45. case "$words[1]" in
  46. list)
  47. _arguments \
  48. '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
  49. '1: :->forms' && return 0
  50. if [[ "$state" == forms ]]; then
  51. _brew_installed_formulae
  52. _requested installed_formulae expl 'installed formulae' compadd -a installed_formulae
  53. fi ;;
  54. install|home|log|info|uses|cat|deps)
  55. _brew_all_formulae
  56. _wanted formulae expl 'all formulae' compadd -a formulae ;;
  57. remove|edit|xo)
  58. _brew_installed_formulae
  59. _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
  60. esac