Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completions/bash: complete names of commands #7455

Merged
merged 1 commit into from Apr 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions completions/bash/brew
Expand Up @@ -94,6 +94,13 @@ __brew_complete_tapped() {
__brewcomp "$taps"
}

__brew_complete_commands() {
local cur="${COMP_WORDS[COMP_CWORD]}"
# Do not auto-complete "*instal" or "*uninstal" aliases for "*install" commands.
local cmds="$(brew commands --quiet --include-aliases | \grep -v instal$)"
COMPREPLY=($(compgen -W "$cmds" -- "$cur"))
}

_brew_analytics() {
case "$COMP_CWORD" in
2) __brewcomp "off on regenerate-uuid state" ;;
Expand Down Expand Up @@ -816,10 +823,7 @@ _brew() {

if [[ "$i" -eq "$COMP_CWORD" ]]
then
# Do not auto-complete "*instal" or "*uninstal" aliases for "*install" commands.
# Prefix newline to prevent not checking the first command.
local cmds=$'\n'"$(brew commands --quiet --include-aliases | \grep -v instal$)"
__brewcomp "$cmds"
__brew_complete_commands
return
fi

Expand All @@ -834,6 +838,7 @@ _brew() {
cask) _brew_cask ;;
cat) __brew_complete_formulae ;;
cleanup) _brew_cleanup ;;
command) __brew_complete_commands ;;
create) _brew_create ;;
deps) _brew_deps ;;
desc) _brew_desc ;;
Expand All @@ -842,6 +847,7 @@ _brew() {
edit) __brew_complete_formulae ;;
fetch) _brew_fetch ;;
gist-logs) _brew_gist_logs ;;
help) __brew_complete_commands ;;
home|homepage) __brew_complete_formulae ;;
info|abv) _brew_info ;;
install|instal) _brew_install ;;
Expand All @@ -855,6 +861,7 @@ _brew() {
outdated) _brew_outdated ;;
pin) __brew_complete_formulae ;;
postinstall) _brew_postinstall ;;
prof) __brew_complete_commands ;;
pull) _brew_pull ;;
readall) _brew_readall ;;
reinstall) _brew_install ;;
Expand Down