_brew 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. 'link:link a formula'
  33. 'list:list files in a formula or not-installed formulae'
  34. 'log:git commit log for a formula'
  35. 'missing:check all installed formuale for missing dependencies.'
  36. 'outdated:list formulae for which a newer version is available'
  37. 'pin:pin specified formulae'
  38. 'postinstall:perform post_install for a given formula'
  39. 'prune:remove dead links'
  40. 'remove:remove a formula'
  41. 'search:search for a formula (/regex/ or string)'
  42. 'switch:switch linkage between installed versions of a formula'
  43. 'tap:tap a new formula repository from GitHub, or list existing taps'
  44. 'test-bot:test a formula and build a bottle'
  45. 'uninstall:uninstall a formula'
  46. 'unlink:unlink a formula'
  47. 'unpin:unpin specified formulae'
  48. 'untap:remove a tapped repository'
  49. 'update:pull latest repository'
  50. 'upgrade:upgrade outdated formulae'
  51. 'uses:show formulae which depend on a formula'
  52. )
  53. local expl
  54. local -a formulae installed_formulae installed_taps outdated_formulae
  55. _arguments \
  56. '(-v)-v[verbose]' \
  57. '(--cellar)--cellar[brew cellar]' \
  58. '(--config)--config[brew configuration]' \
  59. '(--env)--env[brew environment]' \
  60. '(--repository)--repository[brew repository]' \
  61. '(--version)--version[version information]' \
  62. '(--prefix)--prefix[where brew lives on this system]' \
  63. '(--cache)--cache[brew cache]' \
  64. '(--force)--force[brew force]' \
  65. '*:: :->subcmds' && return 0
  66. if (( CURRENT == 1 )); then
  67. _describe -t commands "brew subcommand" _1st_arguments
  68. return
  69. fi
  70. case "$words[1]" in
  71. install|reinstall|audit|home|homepage|log|info|abv|uses|cat|deps|edit|options)
  72. _brew_all_formulae
  73. _wanted formulae expl 'all formulae' compadd -a formulae ;;
  74. list|ls)
  75. _arguments \
  76. '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
  77. '(--pinned)--pinned[list all versions of pinned formulae]' \
  78. '(--versions)--versions[list all installed versions of a formula]' \
  79. '1: :->forms' && return 0
  80. if [[ "$state" == forms ]]; then
  81. _brew_installed_formulae
  82. _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
  83. fi ;;
  84. remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin)
  85. _brew_installed_formulae
  86. _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
  87. search|-S)
  88. _arguments \
  89. '(--macports)--macports[search the macports repository]' \
  90. '(--fink)--fink[search the fink repository]' ;;
  91. untap)
  92. _brew_installed_taps
  93. _wanted installed_taps expl 'installed taps' compadd -a installed_taps ;;
  94. upgrade)
  95. _brew_outdated_formulae
  96. _wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;;
  97. esac