brew.plugin.zsh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #compdef brew
  2. # copied from _fink
  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. 'install:install a formula'
  12. 'remove:remove a formula'
  13. 'search:search for a formula (/regex/ or string)'
  14. 'list:list files in a formula or not-installed formulae'
  15. 'link:link a formula'
  16. 'unlink:unlink a formula'
  17. 'home:visit the homepage of a formula or the brew project'
  18. 'info:information about a formula'
  19. 'prune:remove dead links'
  20. 'update:freshen up links'
  21. 'log:git commit log for a formula'
  22. 'create:create a new formula'
  23. 'edit:edit a formula'
  24. )
  25. local expl
  26. local -a formula installed_formulae
  27. _arguments \
  28. '(-v --verbose)'{-v,--verbose}'[verbose]' \
  29. '(--version)--version[version information]' \
  30. '(--prefix)--prefix[where brew lives on this system]' \
  31. '(--cache)--cache[brew cache]' \
  32. '*:: :->subcmds' && return 0
  33. if (( CURRENT == 1 )); then
  34. _describe -t commands "brew subcommand" _1st_arguments
  35. return
  36. fi
  37. case "$words[1]" in
  38. list)
  39. _arguments \
  40. '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
  41. '1: :->forms' && return 0
  42. if [[ "$state" == forms ]]; then
  43. _brew_installed_formulae
  44. _requested installed_formulae expl 'installed formulae' compadd -a installed_formulae
  45. fi ;;
  46. install|home|log|info)
  47. _brew_all_formulae
  48. _wanted formulae expl 'all formulae' compadd -a formulae ;;
  49. remove|edit|xo)
  50. _brew_installed_formulae
  51. _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
  52. esac