brew.plugin.zsh 2.0 KB

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