_brew 2.8 KB

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