_brew 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. 'missing:check all installed formuale for missing dependencies.'
  25. 'outdated:list formulas for which a newer version is available'
  26. 'prune:remove dead links'
  27. 'remove:remove a formula'
  28. 'search:search for a formula (/regex/ or string)'
  29. 'server:start a local web app that lets you browse formulae (requires Sinatra)'
  30. 'unlink:unlink a formula'
  31. 'update:freshen up links'
  32. 'upgrade:upgrade outdated formulae'
  33. 'uses:show formulas which depend on a formula'
  34. )
  35. local expl
  36. local -a formulae installed_formulae
  37. _arguments \
  38. '(-v)-v[verbose]' \
  39. '(--cellar)--cellar[brew cellar]' \
  40. '(--config)--config[brew configuration]' \
  41. '(--env)--env[brew environment]' \
  42. '(--repository)--repository[brew repository]' \
  43. '(--version)--version[version information]' \
  44. '(--prefix)--prefix[where brew lives on this system]' \
  45. '(--cache)--cache[brew cache]' \
  46. '*:: :->subcmds' && return 0
  47. if (( CURRENT == 1 )); then
  48. _describe -t commands "brew subcommand" _1st_arguments
  49. return
  50. fi
  51. case "$words[1]" in
  52. search|-S)
  53. _arguments \
  54. '(--macports)--macports[search the macports repository]' \
  55. '(--fink)--fink[search the fink repository]' ;;
  56. list|ls)
  57. _arguments \
  58. '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
  59. '(--versions)--versions[list all installed versions of a formula]' \
  60. '1: :->forms' && return 0
  61. if [[ "$state" == forms ]]; then
  62. _brew_installed_formulae
  63. _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
  64. fi ;;
  65. install|home|homepage|log|info|abv|uses|cat|deps|edit|options)
  66. _brew_all_formulae
  67. _wanted formulae expl 'all formulae' compadd -a formulae ;;
  68. remove|rm|uninstall|unlink|cleanup|link|ln)
  69. _brew_installed_formulae
  70. _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
  71. esac