_brew 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. _brew_installed_taps() {
  11. installed_taps=(`brew tap`)
  12. }
  13. _brew_outdated_formulae() {
  14. outdated_formulae=(`brew outdated`)
  15. }
  16. local -a _1st_arguments
  17. _1st_arguments=(
  18. 'audit:check formulae for Homebrew coding style'
  19. 'cat:display formula file for a formula'
  20. 'cleanup:uninstall unused and old versions of packages'
  21. 'commands:show a list of commands'
  22. 'create:create a new formula'
  23. 'deps:list dependencies of a formula'
  24. 'doctor:audits your installation for common issues'
  25. 'edit:edit a formula'
  26. 'fetch:download formula resources to the cache'
  27. 'gist-logs:generate a gist of the full build logs'
  28. 'home:visit the homepage of a formula or the brew project'
  29. 'info:information about a formula'
  30. 'install:install a formula'
  31. 'reinstall:install a formula anew; re-using its current options'
  32. 'leaves:show installed formulae that are not dependencies of another installed formula'
  33. 'link:link a formula'
  34. 'list:list files in a formula or not-installed formulae'
  35. 'log:git commit log for a formula'
  36. 'missing:check all installed formuale for missing dependencies.'
  37. 'outdated:list formulae for which a newer version is available'
  38. 'pin:pin specified formulae'
  39. 'postinstall:perform post_install for a given formula'
  40. 'prune:remove dead links'
  41. 'remove:remove a formula'
  42. 'search:search for a formula (/regex/ or string)'
  43. 'switch:switch linkage between installed versions of a formula'
  44. 'tap:tap a new formula repository from GitHub, or list existing taps'
  45. 'test-bot:test a formula and build a bottle'
  46. 'uninstall:uninstall a formula'
  47. 'unlink:unlink a formula'
  48. 'unpin:unpin specified formulae'
  49. 'untap:remove a tapped repository'
  50. 'update:pull latest repository'
  51. 'upgrade:upgrade outdated formulae'
  52. 'uses:show formulae which depend on a formula'
  53. )
  54. local expl
  55. local -a formulae installed_formulae installed_taps outdated_formulae
  56. _arguments \
  57. '(-v)-v[verbose]' \
  58. '(--cellar)--cellar[brew cellar]' \
  59. '(--config)--config[brew configuration]' \
  60. '(--env)--env[brew environment]' \
  61. '(--repository)--repository[brew repository]' \
  62. '(--version)--version[version information]' \
  63. '(--prefix)--prefix[where brew lives on this system]' \
  64. '(--cache)--cache[brew cache]' \
  65. '(--force)--force[brew force]' \
  66. '*:: :->subcmds' && return 0
  67. if (( CURRENT == 1 )); then
  68. _describe -t commands "brew subcommand" _1st_arguments
  69. return
  70. fi
  71. case "$words[1]" in
  72. install|reinstall|audit|home|homepage|log|info|abv|uses|cat|deps|edit|options)
  73. _brew_all_formulae
  74. _wanted formulae expl 'all formulae' compadd -a formulae ;;
  75. list|ls)
  76. _arguments \
  77. '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
  78. '(--pinned)--pinned[list all versions of pinned formulae]' \
  79. '(--versions)--versions[list all installed versions of a formula]' \
  80. '1: :->forms' && return 0
  81. if [[ "$state" == forms ]]; then
  82. _brew_installed_formulae
  83. _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
  84. fi ;;
  85. remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin)
  86. _brew_installed_formulae
  87. _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
  88. search|-S)
  89. _arguments \
  90. '(--macports)--macports[search the macports repository]' \
  91. '(--fink)--fink[search the fink repository]' ;;
  92. untap)
  93. _brew_installed_taps
  94. _wanted installed_taps expl 'installed taps' compadd -a installed_taps ;;
  95. upgrade)
  96. _brew_outdated_formulae
  97. _wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;;
  98. esac