_brew 2.7 KB

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