Skip to content

Commit c5253b2

Browse files
committed
Remove fish command completions for excluded commands
This removes fish command completions (but keeps argument completions) for commands in the `COMPLETIONS_EXCLUSION_LIST` list. It also removes unnecessary exclusions of `*instal` aliases in command suggestions in bash and fish completions, since those were removed from `internal_commands_list.txt` in #10229. This makes `COMPLETIONS_EXCLUSION_LIST` the single source of truth for commands to exclude from completions.
1 parent 0b25b5c commit c5253b2

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

Library/Homebrew/completions.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ def self.generate_fish_subcommand_completion(command)
304304
return unless command_gets_completions? command
305305

306306
command_description = format_description Commands.command_description(command, short: true), fish: true
307-
lines = ["__fish_brew_complete_cmd '#{command}' '#{command_description}'"]
307+
lines = if COMPLETIONS_EXCLUSION_LIST.include?(command)
308+
[]
309+
else
310+
["__fish_brew_complete_cmd '#{command}' '#{command_description}'"]
311+
end
308312

309313
options = command_options(command).sort.filter_map do |opt, desc|
310314
arg_line = "__fish_brew_complete_arg '#{command}' -l #{opt.sub(/^-+/, "")}"

Library/Homebrew/completions/bash.erb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ __brew_complete_tapped() {
108108

109109
__brew_complete_commands() {
110110
# Auto-complete Homebrew commands
111-
# Do NOT auto-complete "*instal" aliases for "*install" commands
112111

113112
local cur="${COMP_WORDS[COMP_CWORD]}"
114113
local cmds
@@ -118,10 +117,10 @@ __brew_complete_commands() {
118117
cmds=${__HOMEBREW_COMMANDS}
119118
elif [[ -n ${HOMEBREW_CACHE:-} && -f ${HOMEBREW_CACHE}/all_commands_list.txt ]]
120119
then
121-
cmds="$(< "${HOMEBREW_CACHE}/all_commands_list.txt" \grep -v instal$)"
120+
cmds="$(< "${HOMEBREW_CACHE}/all_commands_list.txt")"
122121
elif [[ -n ${HOMEBREW_REPOSITORY:-} && -f ${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt ]]
123122
then
124-
cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt" \grep -v instal$)"
123+
cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt")"
125124
fi
126125
while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${cmds}" -- "${cur}")
127126
export __HOMEBREW_COMMANDS=${cmds}

Library/Homebrew/completions/fish.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ end
147147

148148
function __fish_brew_suggest_commands -d "Lists all commands names, including aliases"
149149
if test -f (brew --cache)/all_commands_list.txt
150-
cat (brew --cache)/all_commands_list.txt | \grep -v instal\$
150+
cat (brew --cache)/all_commands_list.txt
151151
else
152-
cat (brew --repo)/completions/internal_commands_list.txt | \grep -v instal\$
152+
cat (brew --repo)/completions/internal_commands_list.txt
153153
end
154154
end
155155

completions/bash/brew

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ __brew_complete_tapped() {
9595

9696
__brew_complete_commands() {
9797
# Auto-complete Homebrew commands
98-
# Do NOT auto-complete "*instal" aliases for "*install" commands
9998

10099
local cur="${COMP_WORDS[COMP_CWORD]}"
101100
local cmds
@@ -105,10 +104,10 @@ __brew_complete_commands() {
105104
cmds=${__HOMEBREW_COMMANDS}
106105
elif [[ -n ${HOMEBREW_CACHE:-} && -f ${HOMEBREW_CACHE}/all_commands_list.txt ]]
107106
then
108-
cmds="$(< "${HOMEBREW_CACHE}/all_commands_list.txt" \grep -v instal$)"
107+
cmds="$(< "${HOMEBREW_CACHE}/all_commands_list.txt")"
109108
elif [[ -n ${HOMEBREW_REPOSITORY:-} && -f ${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt ]]
110109
then
111-
cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt" \grep -v instal$)"
110+
cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt")"
112111
fi
113112
while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${cmds}" -- "${cur}")
114113
export __HOMEBREW_COMMANDS=${cmds}

completions/fish/brew.fish

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ end
134134

135135
function __fish_brew_suggest_commands -d "Lists all commands names, including aliases"
136136
if test -f (brew --cache)/all_commands_list.txt
137-
cat (brew --cache)/all_commands_list.txt | \grep -v instal\$
137+
cat (brew --cache)/all_commands_list.txt
138138
else
139-
cat (brew --repo)/completions/internal_commands_list.txt | \grep -v instal\$
139+
cat (brew --repo)/completions/internal_commands_list.txt
140140
end
141141
end
142142

@@ -867,7 +867,6 @@ __fish_brew_complete_arg 'info; and not __fish_seen_argument -l cask -l casks' -
867867
__fish_brew_complete_arg 'info; and not __fish_seen_argument -l formula -l formulae' -a '(__fish_brew_suggest_casks_all)'
868868

869869

870-
__fish_brew_complete_cmd 'instal' 'Install a formula or cask'
871870
__fish_brew_complete_arg 'instal' -l HEAD -d 'If formula defines it, install the HEAD version, aka. main, trunk, unstable, master'
872871
__fish_brew_complete_arg 'instal' -l adopt -d 'Adopt existing artifacts in the destination that are identical to those being installed. Cannot be combined with `--force`'
873872
__fish_brew_complete_arg 'instal' -l appdir -d 'Target location for Applications (default: `/Applications`)'
@@ -1612,7 +1611,6 @@ __fish_brew_complete_arg 'unbottled' -l verbose -d 'Make some output more verbos
16121611
__fish_brew_complete_arg 'unbottled' -a '(__fish_brew_suggest_formulae_all)'
16131612

16141613

1615-
__fish_brew_complete_cmd 'uninstal' 'Uninstall a formula or cask'
16161614
__fish_brew_complete_arg 'uninstal' -l cask -d 'Treat all named arguments as casks'
16171615
__fish_brew_complete_arg 'uninstal' -l debug -d 'Display any debugging information'
16181616
__fish_brew_complete_arg 'uninstal' -l force -d 'Delete all installed versions of formula. Uninstall even if cask is not installed, overwrite existing files and ignore errors when removing files'
@@ -1728,7 +1726,6 @@ __fish_brew_complete_arg 'update-python-resources' -l version -d 'Use the specif
17281726
__fish_brew_complete_arg 'update-python-resources' -a '(__fish_brew_suggest_formulae_all)'
17291727

17301728

1731-
__fish_brew_complete_cmd 'update-report' 'The Ruby implementation of `brew update`'
17321729
__fish_brew_complete_arg 'update-report' -l auto-update -d 'Run in \'auto-update\' mode (faster, less output)'
17331730
__fish_brew_complete_arg 'update-report' -l debug -d 'Display any debugging information'
17341731
__fish_brew_complete_arg 'update-report' -l force -d 'Treat installed and updated formulae as if they are from the same taps and migrate them anyway'

0 commit comments

Comments
 (0)