Use commands cache in bash/fish completions
This commit is contained in:
parent
287659c200
commit
01f78582fa
@ -96,8 +96,12 @@ __brew_complete_tapped() {
|
||||
|
||||
__brew_complete_commands() {
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
HOMEBREW_CACHE=$(brew --cache)
|
||||
HOMEBREW_REPOSITORY=$(brew --repo)
|
||||
# Do not auto-complete "*instal" or "*uninstal" aliases for "*install" commands.
|
||||
local cmds="$(brew commands --quiet --include-aliases | \grep -v instal$)"
|
||||
[[ -f "$HOMEBREW_CACHE/all_commands_list.txt" ]] &&
|
||||
local cmds="$(cat "$HOMEBREW_CACHE/all_commands_list.txt" | \grep -v instal$)" ||
|
||||
local cmds="$(cat "$HOMEBREW_REPOSITORY/completions/internal_commands_list.txt" | \grep -v instal$)"
|
||||
COMPREPLY=($(compgen -W "$cmds" -- "$cur"))
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,11 @@ function __fish_brew_suggest_taps_pinned -d "List only pinned taps"
|
||||
end
|
||||
|
||||
function __fish_brew_suggest_commands -d "Lists all commands names, including aliases"
|
||||
brew commands --quiet --include-aliases
|
||||
if test -f (brew --cache)/all_commands_list.txt
|
||||
cat (brew --cache)/all_commands_list.txt | \grep -v instal\$
|
||||
else
|
||||
cat (brew --repo)/completions/internal_commands_list.txt | \grep -v instal\$
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: any better way to list available services?
|
||||
|
Loading…
x
Reference in New Issue
Block a user