_brew 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #compdef brew
  2. #autoload
  3. # imported from https://github.com/Homebrew/homebrew/blob/29f73d2212c2b202fe25f69dcbf440d8391fa4c9/Library/Contributions/brew_zsh_completion.zsh
  4. # Brew ZSH completion function
  5. # Drop this somewhere in your $fpath (like /usr/share/zsh/site-functions)
  6. # and rename it _brew
  7. #
  8. # altered from _fink
  9. _brew_all_formulae() {
  10. formulae=(`brew search`)
  11. }
  12. _brew_installed_formulae() {
  13. installed_formulae=(`brew list`)
  14. }
  15. _brew_installed_taps() {
  16. installed_taps=(`brew tap`)
  17. }
  18. _brew_official_taps() {
  19. official_taps=(`brew tap --list-official`)
  20. }
  21. _brew_pinned_taps() {
  22. pinned_taps=(`brew tap --list-pinned`)
  23. }
  24. _brew_outdated_formulae() {
  25. outdated_formulae=(`brew outdated`)
  26. }
  27. local -a _1st_arguments
  28. _1st_arguments=(
  29. 'audit:check formulae for Homebrew coding style'
  30. 'cat:display formula file for a formula'
  31. 'cleanup:uninstall unused and old versions of packages'
  32. 'commands:show a list of commands'
  33. 'config:show homebrew and system configuration'
  34. 'create:create a new formula'
  35. 'deps:list dependencies and dependants of a formula'
  36. 'desc:display a description of a formula'
  37. 'doctor:audits your installation for common issues'
  38. 'edit:edit a formula'
  39. 'fetch:download formula resources to the cache'
  40. 'gist-logs:generate a gist of the full build logs'
  41. 'home:visit the homepage of a formula or the brew project'
  42. 'info:information about a formula'
  43. 'install:install a formula'
  44. 'reinstall:install a formula anew; re-using its current options'
  45. 'leaves:show installed formulae that are not dependencies of another installed formula'
  46. 'link:link a formula'
  47. 'linkapps:symlink .app bundles provided by formulae into /Applications'
  48. 'list:list files in a formula or not-installed formulae'
  49. 'log:git commit log for a formula'
  50. 'missing:check all installed formuale for missing dependencies.'
  51. 'migrate:migrate renamed formula to new name'
  52. 'outdated:list formulae for which a newer version is available'
  53. 'pin:pin specified formulae'
  54. 'postinstall:perform post_install for a given formula'
  55. 'prune:remove dead links'
  56. 'remove:remove a formula'
  57. 'search:search for a formula (/regex/ or string)'
  58. 'switch:switch between different versions of a formula'
  59. 'tap:tap a new formula repository from GitHub, or list existing taps'
  60. 'tap-info:information about a tap'
  61. 'tap-pin:pin a tap'
  62. 'tap-unpin:unpin a tap'
  63. 'test-bot:test a formula and build a bottle'
  64. 'uninstall:uninstall a formula'
  65. 'unlink:unlink a formula'
  66. 'unlinkapps:remove symlinked .app bundles provided by formulae from /Applications'
  67. 'unpin:unpin specified formulae'
  68. 'untap:remove a tapped repository'
  69. 'update:fetch latest version of Homebrew and all formulae'
  70. 'upgrade:upgrade outdated formulae'
  71. 'uses:show formulae which depend on a formula'
  72. `brew commands --quiet --include-aliases`
  73. )
  74. local expl
  75. local -a formulae installed_formulae installed_taps official_taps outdated_formulae
  76. _arguments \
  77. '(-v)-v[verbose]' \
  78. '(--cellar)--cellar[brew cellar]' \
  79. '(--env)--env[brew environment]' \
  80. '(--repository)--repository[brew repository]' \
  81. '(--version)--version[version information]' \
  82. '(--prefix)--prefix[where brew lives on this system]' \
  83. '(--cache)--cache[brew cache]' \
  84. '*:: :->subcmds' && return 0
  85. if (( CURRENT == 1 )); then
  86. _describe -t commands "brew subcommand" _1st_arguments
  87. return
  88. fi
  89. case "$words[1]" in
  90. install|reinstall|audit|home|homepage|log|info|abv|uses|cat|deps|desc|edit|options|switch)
  91. _brew_all_formulae
  92. _wanted formulae expl 'all formulae' compadd -a formulae ;;
  93. linkapps|unlinkapps)
  94. _arguments \
  95. '(--local)--local[operate on ~/Applications instead of /Applications]' \
  96. '1: :->forms' && return 0
  97. if [[ "$state" == forms ]]; then
  98. _brew_installed_formulae
  99. _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
  100. fi ;;
  101. list|ls)
  102. _arguments \
  103. '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
  104. '(--pinned)--pinned[list all versions of pinned formulae]' \
  105. '(--versions)--versions[list all installed versions of a formula]' \
  106. '1: :->forms' && return 0
  107. if [[ "$state" == forms ]]; then
  108. _brew_installed_formulae
  109. _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
  110. fi ;;
  111. remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin)
  112. _brew_installed_formulae
  113. _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
  114. search|-S)
  115. _arguments \
  116. '(--macports)--macports[search the macports repository]' \
  117. '(--fink)--fink[search the fink repository]' ;;
  118. untap|tap-info|tap-pin)
  119. _brew_installed_taps
  120. _wanted installed_taps expl 'installed taps' compadd -a installed_taps ;;
  121. tap)
  122. _brew_official_taps
  123. _wanted official_taps expl 'official taps' compadd -a official_taps ;;
  124. tap-unpin)
  125. _brew_pinned_taps
  126. _wanted pinned_taps expl 'pinned taps' compadd -a pinned_taps ;;
  127. upgrade)
  128. _brew_outdated_formulae
  129. _wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;;
  130. esac