_brew 2.7 KB

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