2009-10-26 10:54:32 -04:00
#compdef brew
2015-08-17 15:29:50 +08:00
#autoload
2009-10-26 10:54:32 -04:00
# Brew ZSH completion function
2016-09-12 05:28:14 -05:00
# functions starting with __brew are helper functions that complete or list
# various types of items.
# functions starting with _brew_ are completions for brew commands
# this mechanism can be extended by external commands by defining a function
# named _brew_<external-name>. See _brew_cask for an example of this.
# a list of aliased internal commands
__brew_list_aliases() {
local -a aliases
aliases=(
ls list
homepage home
'-S' search
up update
ln link
instal install
rm uninstall
remove uninstall
configure diy
abv info
dr doctor
'--repo' '--repository'
environment '--env'
'--config' config
'-v' '--version'
)
echo "${aliases}"
}
2018-06-11 15:35:55 -04:00
__brew_formulae_or_ruby_files() {
_alternative 'formulae::__brew_formulae' \
2019-08-19 14:40:03 -04:00
'files:files:{_files -g "*.rb"}'
2018-06-11 15:35:55 -04:00
}
2018-12-13 09:11:33 +01:00
# completions remain in cache until any tap has new commits
2018-12-13 08:44:27 +01:00
__brew_completion_caching_policy() {
2019-03-05 10:57:19 -06:00
local -a tmp
# invalidate if cache file is missing or >=2 weeks old
tmp=( $1(mw-2N) )
(( $#tmp )) || return 0
2020-06-17 23:02:46 +03:00
# otherwise, invalidate if latest tap index file is missing or newer than cache file
2019-03-05 10:57:19 -06:00
tmp=( ${HOMEBREW_REPOSITORY:-/usr/local/Homebrew}/Library/Taps/*/*/.git/index(om[1]N) )
[[ -z $tmp || $tmp -nt $1 ]]
2018-12-10 22:35:14 +01:00
}
2016-09-12 05:28:14 -05:00
__brew_formulae() {
2020-06-17 23:02:46 +03:00
local -a list
2018-12-10 22:35:14 +01:00
local comp_cachename=brew_formulae
2020-06-17 23:02:46 +03:00
if ! _retrieve_cache $comp_cachename; then
list=( $(brew search) )
_store_cache $comp_cachename list
2018-12-10 22:35:14 +01:00
fi
2020-06-17 23:02:46 +03:00
_describe -t formulae 'all formulae' list
2016-09-12 05:28:14 -05:00
}
__brew_installed_formulae() {
local -a formulae
formulae=($(brew list))
_describe -t formulae 'installed formulae' formulae
}
__brew_outdated_formulae() {
local -a formulae
formulae=($(brew outdated))
_describe -t formulae 'outdated formulae' formulae
}
__brew_installed_taps() {
local -a taps
taps=($(brew tap))
_describe -t installed-taps 'installed taps' taps
}
__brew_pinned_taps() {
local -a taps
taps=($(brew tap --list-pinned))
_describe -t pinned-taps 'pinned taps' taps
}
__brew_any_tap() {
_alternative \
2018-03-31 13:42:33 +01:00
'installed-taps:installed taps:__brew_installed_taps'
2016-09-12 05:28:14 -05:00
}
__brew_common_commands() {
local -a commands
commands=(
'audit:check formulae for Homebrew coding style'
'cat:display formula file for a formula'
'cleanup:uninstall unused and old versions of packages'
'commands:show a list of commands'
'config:show homebrew and system configuration'
'create:create a new formula'
2016-10-17 00:02:54 -04:00
'deps:list dependencies of formulae'
2016-09-12 05:28:14 -05:00
'desc:display a description of a formula'
'doctor:audits your installation for common issues'
'edit:edit a formula'
'fetch:download formula resources to the cache'
2017-02-11 16:37:41 -08:00
'formula:the path for a formula'
2016-09-12 05:28:14 -05:00
'gist-logs:generate a gist of the full build logs'
'home:visit the homepage of a formula or the brew project'
'info:information about a formula'
'install:install a formula'
'reinstall:install a formula anew; re-using its current options'
'leaves:show installed formulae that are not dependencies of another installed formula'
'link:link a formula'
'list:list files in a formula or not-installed formulae'
'log:git commit log for a formula'
2019-01-30 21:35:01 +00:00
'missing:check all installed formulae for missing dependencies.'
2016-09-12 05:28:14 -05:00
'migrate:migrate renamed formula to new name'
'outdated:list formulae for which a newer version is available'
'pin:pin specified formulae'
'postinstall:perform post_install for a given formula'
'remove:remove a formula'
2018-07-19 13:39:52 +02:00
'search:search for a formula or cask (/regex/ or string)'
2016-09-12 05:28:14 -05:00
'switch:switch between different versions of a formula'
'tap:tap a new formula repository from GitHub, or list existing taps'
'tap-info:information about a tap'
'test-bot:test a formula and build a bottle'
'uninstall:uninstall a formula'
'unlink:unlink a formula'
'unpin:unpin specified formulae'
'untap:remove a tapped repository'
'update:fetch latest version of Homebrew and all formulae'
'upgrade:upgrade outdated formulae'
'uses:show formulae which depend on a formula'
'--cellar:brew cellar'
'--env:brew environment'
'--repository:brew repository'
'--version:version information'
'--prefix:where brew lives on this system'
'--cache:brew cache'
)
_describe -t common-commands 'common commands' commands
}
__brew_all_commands() {
2020-06-17 23:02:46 +03:00
local -a list
2018-12-09 00:22:47 +01:00
local comp_cachename=brew_all_commands
2020-06-17 23:02:46 +03:00
if ! _retrieve_cache $comp_cachename; then
local cache_dir=$(brew --cache)
[[ -f $cache_dir/all_commands_list.txt ]] &&
list=( $(<$cache_dir/all_commands_list.txt) ) ||
list=( $(<$(brew --repo)/completions/internal_commands_list.txt) )
list=( ${list:#*instal} ) # Exclude instal, uninstal, etc.
_store_cache $comp_cachename list
2018-12-09 00:22:47 +01:00
fi
2020-06-17 23:02:46 +03:00
_describe -t all-commands 'all commands' list
2016-09-12 05:28:14 -05:00
}
__brew_commands() {
# TODO remove duplicates between common and all commands
_alternative \
'common-commands:command:__brew_common_commands' \
'all-commands:command:__brew_all_commands'
}
# brew --cache
# brew --cache formula
_brew___cache() {
__brew_formulae
}
# brew --cellar
# brew --cellar formula
_brew___cellar() {
__brew_formulae
}
# brew --env
_brew___env() {
return 1
}
# brew --prefix
# brew --prefix formula
_brew___prefix() {
__brew_formulae
}
# brew --repository
# brew --repository user/repo
_brew___repository() {
__brew_any_tap
}
# brew --version
_brew___version() {
return 1
}
# brew analytics [state]
# brew analytics (on|off)
# brew analytics regenerate-uuid
_brew_analytics() {
_values 'analytics' \
'off[turn off analytics]' \
'on[turn on analytics]' \
'regenerate-uuid[regenerate UUID used in analytics]' \
'state[display anonymous user behaviour analytics state]'
}
# brew aspell_dictionaries
_brew_aspell_dictionaries() {
return 1
}
# brew audit [--strict] [--online] [--new-formula] [--display-cop-names] [--display-filename] [formulae]
_brew_audit() {
_arguments \
'(--new-formula)--strict[run additional checks including RuboCop style checks]' \
'(--new-formula)--online[run slower checks that require a network connection]' \
2019-08-19 14:27:29 +10:00
'(--online --strict)--new-formula[check if a new formula is eligible for Homebrew. Implies --strict and --online]' \
2016-09-12 05:28:14 -05:00
'--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]' \
2019-08-19 14:40:03 -04:00
'*:formula:__brew_formulae_or_ruby_files'
2016-09-12 05:28:14 -05:00
}
# brew bottle [--verbose] [--no-rebuild] [--keep-old] [--skip-relocation] [--root-url=root_url]
# brew bottle --merge [--no-commit] [--keep-old] [--write]
# TODO missing argument docs
_brew_bottle() {
_arguments \
'--keep-old' \
- set1 \
'--verbose' \
'--no-rebuild' \
'--skip-relocation' \
'--root-url=' \
- set2 \
'--merge' \
'--no-commit' \
'--write'
}
# brew bump-formula-pr [--devel] [--dry-run] [--audit|--strict] --url=url --sha256=sha-256 formula
# brew bump-formula-pr [--devel] [--dry-run] [--audit|--strict] --tag=tag --revision=revision formula
_brew_bump_formula_pr() {
_arguments \
'--devel[bump the development rather than stable version]' \
'--dry-run[print what would be done rather than doing it]' \
'(--strict)--audit[run brew audit before opening the PR]' \
'(--audit)--strict[run brew audit --strict before opening the PR]' \
- set1 \
'--url=-[new url]:url:_urls' \
'--sha256=-[new sha256 checksum]:sha256: ' \
2019-08-19 14:40:03 -04:00
': :__brew_formulae_or_ruby_files' \
2016-09-12 05:28:14 -05:00
- set2 \
'--tag=-[new tag]: ' \
'--revision=-[new revision]: ' \
2019-08-19 14:40:03 -04:00
': :__brew_formulae_or_ruby_files'
2016-09-12 05:28:14 -05:00
}
2019-10-27 02:30:14 -07:00
# brew bump-revision [--dry-run] [--message] formula
_brew_bump_revision() {
_arguments \
'--dry-run[print what would be done rather than doing it]' \
'--message[append message to the default commit message]:message: ' \
': :__brew_formulae_or_ruby_files'
}
2016-09-12 05:28:14 -05:00
# brew cat formula
_brew_cat() {
_arguments \
'1:: :__brew_formulae'
}
# brew cleanup [--prune=days] [--dry-run] [-s] [formulae]
_brew_cleanup() {
_arguments \
'--prune=-[remove all cache files older than days]:days: ' \
'(--dry-run,-n)'{--dry-run,-n}'[show what would be removed, but do not actually remove anything]' \
'-s[scrub cache]' \
'*::formula:__brew_formulae'
}
# brew command cmd
_brew_command() {
_arguments \
': :__brew_all_commands'
}
# brew commands [--quiet [--include-aliases]]
_brew_commands() {
_arguments '--quiet' && return 0
_arguments '--include-aliases'
}
# brew config
_brew_config() {
return 1
}
# brew create URL [--autotools|--cmake] [--no-fetch] [--set-name name] [--set-version version] [--tap user/repo]:
_brew_create() {
_arguments \
'(--cmake)--autotools[create a basic template for an Autotools-style build]' \
'(--autotools)--cmake[create a basic template for a CMake-style build]' \
'--no-fetch[don''t download URL to the cache]' \
'--set-name:name: ' \
'--set-version:version: ' \
'--tap:tap:__brew_installed_taps' \
':url:_urls'
}
2017-08-03 00:41:51 -04:00
# brew deps [--1] [-n] [--union] [--full-name] [--installed] [--include-build] [--include-optional] [--skip-recommended] [--include-requirements] formulae
# brew deps --tree [--1] [filters] (formulae|--installed)
2016-09-12 05:28:14 -05:00
# brew deps [filters] (--installed|--all)
# The filters placeholder is any combination of options --include-build, --include-optional, and --skip-recommended as documented above.
_brew_deps() {
_arguments \
- formulae-deps \
2016-10-17 00:02:54 -04:00
'--include-build[include \:build dependencies]' \
'--include-optional[include \:optional dependencies]' \
'--skip-recommended[skip \:recommended type dependencies]' \
2017-08-03 00:41:51 -04:00
'--include-requirements[include requirements]' \
2016-09-12 05:28:14 -05:00
'--1[only show dependencies one level down, instead of recursing]' \
'-n[show dependencies in topological order]' \
'--union[show the union of dependencies for formulae, instead of the intersection]' \
'--full-name[list dependencies by their full name]' \
2016-10-17 00:02:54 -04:00
'--installed[only list currently installed dependencies, or show dependencies for all installed formulae]' \
2016-09-12 05:28:14 -05:00
'*:formulae:__brew_formulae' \
- tree-deps \
2016-10-17 00:02:54 -04:00
'--tree[show dependencies as a tree]' \
'(*)--installed[show dependencies for all installed formulae]' \
2017-08-03 00:41:51 -04:00
'--include-build[include \:build dependencies]' \
'--include-optional[include \:optional dependencies]' \
'--skip-recommended[skip \:recommended type dependencies]' \
'--include-requirements[include requirements]' \
'--1[only show dependencies one level down, instead of recursing]' \
2016-09-12 05:28:14 -05:00
'(--installed)*:formulae:__brew_formulae' \
- installed-all \
2016-10-17 00:02:54 -04:00
'--include-build[include \:build dependencies]' \
'--include-optional[include \:optional dependencies]' \
'--skip-recommended[skip \:recommended type dependencies]' \
'(--all)--installed[show dependencies for all installed formulae]' \
'(--installed)--all[show dependencies for all available formulae]'
2016-09-12 05:28:14 -05:00
}
2018-05-22 03:17:53 -04:00
# brew desc formulae
2016-09-12 05:28:14 -05:00
# brew desc [-s|-n|-d] pattern
_brew_desc() {
_arguments \
- desc-formula \
2018-05-22 03:17:53 -04:00
'*: : __brew_formulae' \
2016-09-12 05:28:14 -05:00
- desc-pattern \
'(-s -n -d)-s[search both name and description]' \
'(-s -n -d)-n[search only name]' \
'(-s -n -d)-d[search only description]' \
':pattern: '
}
# brew diy [--name=name] [--version=version]
_brew_diy() {
_arguments \
'--name=-:' \
'--version=-:'
}
# brew doctor
_brew_doctor() {
return 1
}
# brew edit
2018-05-22 03:17:53 -04:00
# brew edit formulae
2016-09-12 05:28:14 -05:00
_brew_edit() {
_arguments \
2019-08-19 14:40:03 -04:00
'*:: :__brew_formulae_or_ruby_files'
2016-09-12 05:28:14 -05:00
}
2020-05-22 15:21:51 +08:00
# brew fetch [--force] [--retry] [-v] [--devel|--HEAD] [--deps]
# [--build-from-source|--build-bottle|--force-bottle] formulae
2016-09-12 05:28:14 -05:00
_brew_fetch() {
_arguments \
2020-05-22 15:21:51 +08:00
'(--force -f)'{--force,-f}'[remove previously cached version and re-fetch]' \
2016-09-12 05:28:14 -05:00
'--retry[retry if a download fails or re-download if the checksum of a previously cached version no longer matches]' \
2020-05-22 15:21:51 +08:00
'(--verbose -v)'{--verbose,-v}'[verbose VCS checkout]' \
2016-09-12 05:28:14 -05:00
'(--HEAD)--devel[fetch devel version instead of stable]' \
'(--devel)--HEAD[fetch HEAD version instead of stable]' \
'--deps[also download dependencies for any listed formulae]' \
2020-05-22 15:21:51 +08:00
'(--build-from-source -s --force-bottle --build-bottle)'{--build-from-source,-s}'[download the source rather than a bottle]' \
'(--build-from-source -s --force-bottle)--build-bottle[download the source (for eventual bottling) rather than a bottle]' \
'(--build-from-source -s --build-bottle)--force-bottle[download a bottle if it exists for the current version of OS X, even if it would not be used during installation]' \
2016-09-12 05:28:14 -05:00
'*:formula:__brew_formulae'
}
2017-02-11 16:37:41 -08:00
# brew formula formula:
_brew_formula() {
__brew_formulae
}
2016-09-12 05:28:14 -05:00
# brew gist-logs [--new-issue|-n] formula
_brew_gist_logs() {
_arguments \
'(--new-issue -n)'{--new-issue,-n}'[automatically create a new issue in the appropriate GitHub repository]' \
':formula:__brew_formulae'
}
# brew help command
_brew_help() {
__brew_commands
}
# brew home
# brew home formula
_brew_home() {
__brew_formulae
}
2018-05-22 03:17:53 -04:00
# brew info formulae
2016-09-12 05:28:14 -05:00
# brew info --github formula
# brew info --json=version (--all|--installed|formulae)
_brew_info() {
_arguments \
- formulae-opts \
2018-05-22 03:17:53 -04:00
'*: :__brew_formulae' \
2016-09-12 05:28:14 -05:00
- github-opts \
'--github[open a browser to the GitHub History page for formula]' \
': :__brew_formulae' \
- json-opts \
'--json=-[print a JSON representation of formulae]:version:(v1)' \
'(--all --installed :)--all[get information on all formulae]' \
'(--all --installed :)--installed[get information on installed formulae]' \
2018-05-22 03:17:53 -04:00
'(--all --installed)*: :__brew_formulae'
2016-09-12 05:28:14 -05:00
}
2020-05-22 15:21:51 +08:00
# brew install [--debug] [--env=std|super]
# [--ignore-dependencies|--only-dependencies] [--include-test]
# [--cc=compiler] [--build-from-source|--build-bottle|--force-fottle]
# [--devel|--HEAD] [--fetch-HEAD] [--bottle-arch=architecture] [--keep-tmp] formulae
2016-09-12 05:28:14 -05:00
# brew install --interactive [--git] formula
_brew_install() {
local state
_arguments \
- normal-install \
'--debug[if brewing fails, open an interactive debugging session]' \
-'-env=-[use standard or super environment]:environment:(std super)' \
2020-05-22 15:21:51 +08:00
'(--only-dependencies)--ignore-dependencies[skip installing any dependencies of any kind]' \
'(--ignore-dependencies)--only-dependencies[install the dependencies but do not install the specified formula]' \
2016-09-12 05:28:14 -05:00
'--cc=-[attempt to compile using compiler]:compiler: ' \
2020-05-22 15:21:51 +08:00
'(--build-from-source -s --force-bottle --build-bottle)'{--build-from-source,-s}'[compile the specified formula from source even if a bottle is provided]' \
'(--build-from-source -s --force-bottle)--build-bottle[prepare the formula for eventual bottling during installation, skipping any post-install steps]' \
'(--build-from-source -s --build-bottle)--force-bottle[install from a bottle if it exists for the current version of OS X, even if it would not normally be used for installation]' \
'--include-test[install testing dependencies]' \
2016-09-12 05:28:14 -05:00
'(--devel --HEAD)'{--devel,--HEAD}'[install the development / HEAD version]' \
2020-05-22 15:21:51 +08:00
'--fetch-HEAD[fetch the upstream repository to detect if the HEAD installation of the formula is outdated]' \
'--bottle-arch=-[optimise bottles for the specified architecture]:architecture: ' \
2016-11-11 03:26:42 +05:30
'--keep-tmp[don''t delete temporary files created during installation]' \
2018-06-20 00:54:14 -04:00
'--display-times[display installation times at end of run]' \
2016-09-12 05:28:14 -05:00
'*: : __brew_formulae' \
- interactive-install \
'--interactive[download and patch formula, then open a shell]' \
'--git' \
': : __brew_formulae'
}
# brew irb [--examples]
_brew_irb() {
_arguments '(--examples)--examples'
}
# brew leaves
_brew_leaves() {
return 1
}
2018-05-22 03:17:53 -04:00
# brew ln, link [--overwrite] [--dry-run] [--force] formulae
2016-09-12 05:28:14 -05:00
_brew_link() {
_arguments \
2018-06-20 01:09:40 -04:00
'--overwrite[delete files which already exist in the prefix]' \
2016-09-12 05:28:14 -05:00
'(--dry-run -n)'{--dry-run,-n}'[list files that would be linked or deleted]' \
2018-06-20 01:09:40 -04:00
'--force[allow keg-only formulae to be linked]' \
2018-05-22 03:17:53 -04:00
'*:formula:__brew_installed_formulae'
2016-09-12 05:28:14 -05:00
}
2018-05-22 03:17:53 -04:00
# brew linkage [--test] [--reverse] formulae
2016-09-12 05:28:14 -05:00
_brew_linkage() {
_arguments \
2018-06-20 01:09:40 -04:00
'--test[only display missing libraries]' \
'--reverse[print the dylib followed by the binaries which link to it]' \
2018-05-22 03:17:53 -04:00
'*:formula:__brew_installed_formulae'
2016-09-12 05:28:14 -05:00
}
# brew list, ls [--full-name]:
# brew list, ls --unbrewed:
# brew list, ls [--versions [--multiple]] [--pinned] [formulae]:
2020-10-03 00:36:43 +06:00
# brew list, ls --cask:
2016-09-12 05:28:14 -05:00
_brew_list() {
local state
_arguments \
2020-10-03 00:36:43 +06:00
- formulae \
'--full-name[print formulae with fully-qualified names]' \
'--unbrewed[files in brew --prefix not controlled by brew]' \
'--pinned[list all versions of pinned formulae]' \
'--versions[list all installed versions of a formula]' \
'--multiple[only show formulae with multiple versions installed]' \
'*:: :__brew_installed_formulae' \
- cask \
'--cask[list installed Casks]' \
'*:: :__brew_installed_casks'
2016-09-12 05:28:14 -05:00
}
2018-05-22 03:17:53 -04:00
2020-08-02 00:59:36 +05:30
# brew livecheck [--verbose] [--quiet] [--debug] [--full-name] [--tap user/repo]
# [--installed] [--json] [--all] [--newer-only] formulae
_brew_livecheck() {
_arguments \
'--full-name[Print formulae with fully-qualified name]' \
'--tap[Check the formulae within the given tap, specified as user/repo]' \
'--all[Check all available formulae]' \
2020-09-03 00:41:16 +05:30
'--installed[Check formulae that are currently installed]' \
2020-08-02 00:59:36 +05:30
'--newer-only[Show the latest version only if it is newer than the formula]' \
2020-09-03 00:41:16 +05:30
'--json[Output information in JSON format]' \
'(--quiet,-q)'{--quiet,-q}'[Suppress warnings, do not print a progress bar for JSON output]' \
'(--debug,-d)'{--debug,-d}'[Display any debugging information]' \
'(--verbose,-v)'{--verbose,-v}'[Make some output more verbose]' \
2020-08-02 00:59:36 +05:30
'(--help,-h)'{--help,-h}'[Show the help message]' \
'*:: :__brew_formulae'
}
2016-09-12 05:28:14 -05:00
# brew log [git-log-options] formula ...:
_brew_log() {
__brew_formulae
}
# brew man
_brew_man() {
return 1
}
# brew migrate [--force] formulae:
_brew_migrate() {
_arguments \
2018-06-20 01:09:40 -04:00
'--force[treat installed formulae and passed formulae ike if they are from same taps and migrate them anyway]' \
2016-09-12 05:28:14 -05:00
'*: :__brew_formulae'
}
# brew mirror [--test] formula-name [formula-name ...]:
# TODO missing argument docs
_brew_mirror() {
_arguments \
2018-06-20 01:09:40 -04:00
'--test' \
2016-09-12 05:28:14 -05:00
'*: :__brew_formulae'
}
# brew missing [formulae]:
_brew_missing() {
__brew_formulae
}
# brew options [--compact] (--all|--installed|formulae):
_brew_options() {
_arguments \
2018-06-20 01:09:40 -04:00
'--compact' \
2016-09-12 05:28:14 -05:00
'(--all --installed :)'{--all,--installed}'[show options for all / installed formula]' \
'(--all --installed): :__brew_formulae'
}
2020-10-03 00:36:43 +06:00
# brew outdated [--quiet|--verbose|--json=v1] [--fetch-HEAD] [--cask]:
2016-09-12 05:28:14 -05:00
_brew_outdated() {
_arguments \
2020-10-03 00:36:43 +06:00
- formulae \
'(--quiet --verbose --json)--quiet[list only the names of outdated brews]' \
'(--quiet --verbose --json)--verbose[display detailed version information]' \
'(--quiet --verbose --json)--json=-[output in JSON format]:version:(v1)' \
'--fetch-HEAD[detect if the HEAD installation of the formula is outdated]' \
- cask \
'--cask[list outdated Casks]' \
'--greedy[also list Casks with auto_updates or version \:latest]' \
2016-09-12 05:28:14 -05:00
}
# brew pin formulae:
_brew_pin() {
__brew_formulae
}
# brew postinstall formula:
_brew_postinstall() {
_arguments \
'*:: :__brew_formulae'
}
# pull [--bottle] [--bump] [--clean] [--ignore-whitespace] [--resolve]
# [--branch-okay] [--no-pbcopy] [--no-publish] patch-source [patch-source]
_brew_pull() {
_arguments \
2018-06-20 01:09:40 -04:00
'--bottle[handle bottles]' \
'--bump[automatically reword commit message]' \
'--clean[do not rewrite commits found in the pulled PR]' \
'--ignore-whitespace[ignore whitespace discrepancies when applying diffs]' \
'--resolve[allow user to resolve patches that fail to apply]' \
'--branch-okay[do not warn on pulling branches other than master]' \
'--no-pbcopy[do not copy anything to the system]' \
2020-09-03 00:41:16 +05:30
'--no-publish[do not publish bottles to Bintray]' \
2016-09-12 05:28:14 -05:00
'*:patch source: '
}
2020-04-05 11:08:48 -04:00
# brew pr-pull [--no-upload|--no-publish] [--dry-run] [--clean] [--branch-okay]
2020-05-22 15:21:51 +08:00
# [--resolve] [--workflow] [--artifact] [--bintray-org] [--tap] pull_request
2020-04-05 11:08:48 -04:00
_brew_pr_pull() {
_arguments \
'(--no-upload)--no-publish[download the bottles, apply the bottle commit, and upload the bottles to Bintray, but don''t publish them]' \
'(--no-publish)--no-upload[download the bottles and apply the bottle commit, but don''t upload to Bintray]' \
'--dry-run[print what would be done rather than doing it]' \
'--clean[do not amend the commits from pull requests]' \
'--branch-okay[do not warn if pulling to a branch besides master (useful for testing)]' \
'--resolve[when a patch fails to apply, leave in progress and allow user to resolve, instead of aborting]' \
'--workflow[retrieve artifacts from the specified workflow (default: tests.yml)]' \
'--artifact[download artifacts with the specified name (default: bottles)]' \
'--bintray-org[upload to the specified Bintray organisation (default: homebrew)]' \
'--tap[target repository tap (default: homebrew/core)]' \
'*:pull_request: '
}
2016-09-12 05:28:14 -05:00
# brew readall [tap]:
_brew_readall() {
__brew_installed_taps
}
2018-05-22 03:17:53 -04:00
# brew reinstall formulae:
2020-05-22 15:21:51 +08:00
# mostly copy from brew install
2016-09-12 05:28:14 -05:00
_brew_reinstall() {
_arguments \
2020-05-22 15:21:51 +08:00
- normal-install \
'--debug[if brewing fails, open an interactive debugging session]' \
'(--build-from-source -s --force-bottle)'{--build-from-source,-s}'[compile the specified formula from source even if a bottle is provided]' \
'(--build-from-source -s)--force-bottle[install from a bottle if it exists for the current version of OS X, even if it would not normally be used for installation]' \
'--keep-tmp[don''t delete temporary files created during installation]' \
'--display-times[display installation times at end of run]' \
'*::formula:__brew_installed_formulae' \
- interactive-install \
'--interactive[download and patch formula, then open a shell]' \
'::formula:__brew_installed_formulae'
2016-09-12 05:28:14 -05:00
}
# brew search, -S:
# brew search [--desc] text|/text/:
2020-10-03 00:36:43 +06:00
# brew search (--cask|--debian|--fedora|--fink|--macports|--opensuse|--ubuntu) text:
2016-09-12 05:28:14 -05:00
_brew_search() {
_arguments \
2020-10-03 00:36:43 +06:00
'(--cask --debian --fedora --fink --macports --opensuse --ubuntu)--desc[include description for each package]:text: ' \
'(--desc --cask --debian --fedora --fink --macports --opensuse --ubuntu)'{--debian,--fedora,--fink,--macports,--opensuse,--ubuntu}'[search for text in given package manager''s list]' \
'(--desc --cask --debian --fedora --fink --macports --opensuse
--ubuntu)--cask[search for text in Casks list]'
2016-09-12 05:28:14 -05:00
}
# brew sh [--env=std]:
# TODO missing argument docs
_brew_sh() {
_arguments \
2018-06-20 01:09:40 -04:00
'--env=-:environment:(std)'
2016-09-12 05:28:14 -05:00
}
# brew style [--fix] [--display-cop-names] [formulae|files]:
_brew_style() {
_arguments \
2018-06-20 01:09:40 -04:00
'--fix[fix style violations automatically]' \
'--display-cop-names[include RuboCop name for each violation in output]' \
2018-06-11 15:35:55 -04:00
'*::formula:__brew_formulae_or_ruby_files'
2016-09-12 05:28:14 -05:00
}
# brew switch name version:
_brew_switch() {
2017-08-30 14:36:16 -07:00
local -a versions
if [[ -n ${words[2]} ]]; then
versions=(${$(brew ls "${words[2]}" --versions)#${words[2]}})
fi
_arguments -S \
'1::formula:__brew_formulae' \
"2:: :(${versions[*]})" \
&& ret=0
2016-09-12 05:28:14 -05:00
}
# brew tap:
# brew tap [--full] user/repo [URL]:
# brew tap --repair:
# brew tap --list-pinned:
_brew_tap() {
_arguments \
- empty-args \
- repo-args \
2018-06-20 01:09:40 -04:00
'--full[perform a full clone]' \
2016-09-12 05:28:14 -05:00
'::url:_urls' \
- repair-args \
2018-06-20 01:09:40 -04:00
'--repair' \
2016-09-12 05:28:14 -05:00
- list-pinned \
2018-06-20 01:09:40 -04:00
'--list-pinned[list all pinned taps]'
2016-09-12 05:28:14 -05:00
}
# brew tap-info:
# brew tap-info (--installed|taps):
# brew tap-info --json=version (--installed|taps):
_brew_tap_info() {
_arguments \
'(--installed *)--installed[display information on all installed taps]' \
2018-06-20 01:09:40 -04:00
'--json=-[print a JSON representation of taps]:version:(v1)' \
2016-09-12 05:28:14 -05:00
'(--installed)*:taps:__brew_installed_taps'
}
# brew tap_readme [-v] name:
# TODO missing argument docs (verbose perhaps)
_brew_tap_readme() {
_arguments \
'(-v)-v' \
':name: '
}
2018-05-22 03:17:53 -04:00
# brew test [--devel|--HEAD] [--debug] [--keep-tmp] formulae:
2016-09-12 05:28:14 -05:00
_brew_test() {
_arguments \
'(--devel --HEAD)'{--devel,--HEAD}'[use the development / head version of the formula]' \
2018-06-20 01:09:40 -04:00
'--debug[launch an interactive debugger if test fails]' \
'--keep-tmp[don''t delete temporary files]' \
2019-08-19 14:40:03 -04:00
'*:formula:__brew_formulae_or_ruby_files'
2016-09-12 05:28:14 -05:00
}
# brew test-bot [options] url|formula:
_brew_test_bot() {
_arguments \
'--dry-run' \
'--local' \
'--keep-logs' \
'--cleanup' \
'--clean-cache' \
'--skip-setup' \
'--skip-homebrew' \
'--junit' \
'--no-bottle' \
'--keep-old' \
'--skip-relocation' \
'--HEAD' \
'--tap' \
'--fail-fast' \
'--verbose' \
'--fast' \
'--keep-tmp' \
'--no-pull' \
'--coverage' \
'--ci-master' \
'--ci-pr' \
'--ci-testing' \
'--ci-upload'
}
# brew tests [-v] [--coverage] [--generic] [--no-compat]
2017-06-07 16:25:07 +01:00
# [--only=test_script:test_method] [--seed seed] [--trace] [--online]:
2016-09-12 05:28:14 -05:00
_brew_tests() {
_arguments \
2018-06-20 01:09:40 -04:00
'-v' \
'--coverage' \
'--generic' \
'--no-compat' \
'--only=-:test_method: ' \
'--seed:seed: ' \
'--trace' \
'--online'
2016-09-12 05:28:14 -05:00
}
2018-05-22 03:17:53 -04:00
# brew uninstall, rm, remove [--force] formulae:
2016-09-12 05:28:14 -05:00
_brew_uninstall() {
_arguments \
2018-06-20 01:09:40 -04:00
'--force[delete all installed versions of formula]' \
2018-05-22 03:17:53 -04:00
'*:formula:__brew_installed_formulae'
2016-09-12 05:28:14 -05:00
}
2018-05-22 03:17:53 -04:00
# brew unlink [--dry-run] formulae:
2016-09-12 05:28:14 -05:00
_brew_unlink() {
_arguments \
2018-01-13 14:34:58 +05:30
'(--dry-run -n)'{--dry-run,-n}'[don''t unlink or delete any files]' \
2018-05-22 03:17:53 -04:00
'*:formula:__brew_installed_formulae'
2016-09-12 05:28:14 -05:00
}
# brew unpack [--git|--patch] [--destdir=path] formulae:
_brew_unpack() {
_arguments \
'(--git --patch)--git[initialize a Git repository in the unpacked source]' \
'(--git --patch)--patch[apply patches for formula]' \
2018-06-20 01:09:40 -04:00
'--destdir=-[create subdirectories under path]:path:_directories' \
2018-05-22 03:17:53 -04:00
'*:formula:__brew_formulae'
2016-09-12 05:28:14 -05:00
}
# brew unpin formulae:
_brew_unpin() {
_arguments \
2018-05-22 03:17:53 -04:00
'*:formula:__brew_formulae'
2016-09-12 05:28:14 -05:00
}
# brew update [--merge] [--force]:
_brew_update() {
_arguments \
2018-06-20 01:09:40 -04:00
'--merge[use git merge instead of git rebase]' \
'--force[do a slower full update check]'
2016-09-12 05:28:14 -05:00
}
# brew update_report:
_brew_update_report() {
return 1
}
# brew update-test [--commit=sha1] [--before=date] [--keep-tmp]:
_brew_update_test() {
_arguments \
'(--commit=sha1)--commit=-[use sha1 as the start commit]:sha1: ' \
'(--before=date)--before=-[use the commit at date as the start commit]:date:_dates' \
2018-06-20 01:09:40 -04:00
'--keep-tmp[retain the temporary directory]'
2016-09-12 05:28:14 -05:00
}
# brew upgrade [install-options] [--cleanup] [--fetch-HEAD] [formulae]
# install-options is copied from brew install
_brew_upgrade() {
_arguments \
2020-10-03 00:36:43 +06:00
'--cask[upgrade installed Casks with newer versions]'
2018-06-20 01:09:40 -04:00
'--cleanup[remove previously installed formula version(s)]' \
'--fetch-HEAD[detect if the HEAD installation of the formula is outdated]' \
2016-09-12 05:28:14 -05:00
- normal-install \
'--debug[if brewing fails, open an interactive debugging session]' \
-'-env=-[use standard or super environment]:environment:(std super)' \
'--ignore-dependencies[skip installing any dependencies of any kind]' \
'--only-dependencies[install the dependencies but do not install the specified formula]' \
'--cc=-[attempt to compile using compiler]:compiler: ' \
2020-05-22 15:21:51 +08:00
'(--build-from-source -s --force-bottle)'{--build-from-source,-s}'[compile the specified formula from source even if a bottle is provided]' \
'(--build-from-source -s)--force-bottle[install from a bottle if it exists for the current version of OS X, even if it would not normally be used for installation]' \
2016-09-12 05:28:14 -05:00
'(--devel --HEAD)'{--devel,--HEAD}'[install the development / HEAD version]' \
2016-11-11 04:04:50 +05:30
'--keep-tmp[don''t delete temporary files created during installation]' \
2018-06-20 00:54:14 -04:00
'--display-times[display installation times at end of run]' \
2016-09-12 05:28:14 -05:00
'*: : __brew_outdated_formulae' \
- interactive-install \
'--interactive[download and patch formula, then open a shell]' \
'--git' \
': : __brew_outdated_formulae'
}
# brew uses [--installed] [--recursive] [--include-build] [--include-optional]
# [--skip-recommended] [--devel|--HEAD] formulae:
_brew_uses() {
_arguments \
2018-06-20 01:09:40 -04:00
'--installed[only list installed formulae]' \
'--recursive[resolve more than one level of dependencies]' \
'--include-build[include the :build type dependencies]' \
'--include-optional[include the :optional dependencies]' \
'--skip-recommended[skip :recommended type dependencies]' \
2016-09-12 05:28:14 -05:00
'(--devel --HEAD)'{--devel,--HEAD}'[find cases where formula is used by development / HEAD build]' \
'*:formula:__brew_formulae'
}
# brew vendor-install [target]:
# TODO args missing docs
_brew_vendor_install() {
_arguments \
'--target'
}
# the main completion function
_brew() {
local curcontext="$curcontext" state state_descr line expl
2019-03-05 10:57:19 -06:00
local tmp ret=1
2016-09-12 05:28:14 -05:00
_arguments -C : \
'(-v)-v[verbose]' \
'1:command:->command' \
'*::options:->options' && return 0
case "$state" in
2019-03-05 10:57:19 -06:00
command)
# set default cache policy
2020-06-17 23:02:46 +03:00
zstyle -s ":completion:${curcontext%:*}:*" cache-policy tmp ||
zstyle ":completion:${curcontext%:*}:*" cache-policy __brew_completion_caching_policy
zstyle -s ":completion:${curcontext%:*}:*" use-cache tmp ||
zstyle ":completion:${curcontext%:*}:*" use-cache true
2019-03-05 10:57:19 -06:00
__brew_commands && return 0
;;
2016-09-12 05:28:14 -05:00
options)
local command_or_alias command
local -A aliases
# expand alias e.g. ls -> list
command_or_alias="${line[1]}"
aliases=($(__brew_list_aliases))
command="${aliases[$command_or_alias]:-$command_or_alias}"
# change context to e.g. brew-list
2019-03-05 10:57:19 -06:00
curcontext="${curcontext%:*}-${command}:${curcontext##*:}"
# set default cache policy (we repeat this dance because the context
# service differs from above)
2020-06-17 23:02:46 +03:00
zstyle -s ":completion:${curcontext%:*}:*" cache-policy tmp ||
zstyle ":completion:${curcontext%:*}:*" cache-policy __brew_completion_caching_policy
zstyle -s ":completion:${curcontext%:*}:*" use-cache tmp ||
zstyle ":completion:${curcontext%:*}:*" use-cache true
2016-09-12 05:28:14 -05:00
# call completion for named command e.g. _brew_list
local completion_func="_brew_${command//-/_}"
_call_function ret "${completion_func}" && return ret
_message "a completion function is not defined for command or alias: ${command_or_alias}"
return 1
;;
esac
}
_brew "$@"