_brew 2.6 KB

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