Improve ZSH completion so local formula files are completable

* brew completion in ZSH currently doesn't complete local formula files for most commands.
* Updating the completion script to complete formula files as well as known formulas in places that it would makes sense to do so.
* This includesFixes to __brew_formula_or_ruby_files
  * Remove redundant call to uncached brew search
  * Add missing ""
This commit is contained in:
Louis Bergelson 2019-08-19 14:40:03 -04:00
parent 8f52084598
commit 2927f0698c
No known key found for this signature in database
GPG Key ID: CDB73EA73CD9CF1E

View File

@ -33,10 +33,8 @@ __brew_list_aliases() {
} }
__brew_formulae_or_ruby_files() { __brew_formulae_or_ruby_files() {
local -a formulae
formulae=($(brew search))
_alternative 'formulae::__brew_formulae' \ _alternative 'formulae::__brew_formulae' \
'files:files:{_files -g *.rb}' 'files:files:{_files -g "*.rb"}'
} }
# completions remain in cache until any tap has new commits # completions remain in cache until any tap has new commits
@ -222,7 +220,7 @@ _brew_audit() {
'(--online --strict)--new-formula[check if a new formula is eligible for Homebrew. Implies --strict and --online]' \ '(--online --strict)--new-formula[check if a new formula is eligible for Homebrew. Implies --strict and --online]' \
'--display-cop-names[include RuboCop cop name for each violation in the output]' \ '--display-cop-names[include RuboCop cop name for each violation in the output]' \
'--display-filename[prefix every line of output with the name of the file or formula being audited]' \ '--display-filename[prefix every line of output with the name of the file or formula being audited]' \
'*:formula:__brew_formulae' '*:formula:__brew_formulae_or_ruby_files'
} }
# brew bottle [--verbose] [--no-rebuild] [--keep-old] [--skip-relocation] [--root-url=root_url] # brew bottle [--verbose] [--no-rebuild] [--keep-old] [--skip-relocation] [--root-url=root_url]
@ -253,11 +251,11 @@ _brew_bump_formula_pr() {
- set1 \ - set1 \
'--url=-[new url]:url:_urls' \ '--url=-[new url]:url:_urls' \
'--sha256=-[new sha256 checksum]:sha256: ' \ '--sha256=-[new sha256 checksum]:sha256: ' \
': :__brew_formulae' \ ': :__brew_formulae_or_ruby_files' \
- set2 \ - set2 \
'--tag=-[new tag]: ' \ '--tag=-[new tag]: ' \
'--revision=-[new revision]: ' \ '--revision=-[new revision]: ' \
': :__brew_formulae' ': :__brew_formulae_or_ruby_files'
} }
# brew cat formula # brew cat formula
@ -368,7 +366,7 @@ _brew_doctor() {
# brew edit formulae # brew edit formulae
_brew_edit() { _brew_edit() {
_arguments \ _arguments \
'*:: :__brew_formulae' '*:: :__brew_formulae_or_ruby_files'
} }
# brew fetch [--force] [--retry] [-v] [--devel|--HEAD] [--deps] [--build-from-source|--force-bottle] formulae # brew fetch [--force] [--retry] [-v] [--devel|--HEAD] [--deps] [--build-from-source|--force-bottle] formulae
@ -661,7 +659,7 @@ _brew_test() {
'(--devel --HEAD)'{--devel,--HEAD}'[use the development / head version of the formula]' \ '(--devel --HEAD)'{--devel,--HEAD}'[use the development / head version of the formula]' \
'--debug[launch an interactive debugger if test fails]' \ '--debug[launch an interactive debugger if test fails]' \
'--keep-tmp[don''t delete temporary files]' \ '--keep-tmp[don''t delete temporary files]' \
'*:formula:__brew_formulae' '*:formula:__brew_formulae_or_ruby_files'
} }
# brew test-bot [options] url|formula: # brew test-bot [options] url|formula: