mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Bash completions: cache Homebrew commands
This commit is contained in:
parent
5f99c1cbda
commit
da9e29ced8
@ -100,19 +100,25 @@ __brew_complete_tapped() {
|
||||
}
|
||||
|
||||
__brew_complete_commands() {
|
||||
# Auto-complete Homebrew commands
|
||||
# Do NOT auto-complete "*instal" aliases for "*install" commands
|
||||
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local cmds
|
||||
HOMEBREW_CACHE=$(brew --cache)
|
||||
HOMEBREW_REPOSITORY=$(brew --repo)
|
||||
# Do not auto-complete "*instal" or "*uninstal" aliases for "*install" commands.
|
||||
if [[ -f "${HOMEBREW_CACHE}/all_commands_list.txt" ]]
|
||||
|
||||
if [[ -n ${__HOMEBREW_COMMANDS} ]]
|
||||
then
|
||||
cmds=${__HOMEBREW_COMMANDS}
|
||||
elif [[ -n ${HOMEBREW_CACHE:-} && -f ${HOMEBREW_CACHE}/all_commands_list.txt ]]
|
||||
then
|
||||
cmds="$(< "${HOMEBREW_CACHE}/all_commands_list.txt" \grep -v instal$)"
|
||||
else
|
||||
elif [[ -n ${HOMEBREW_REPOSITORY:-} && -f ${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt ]]
|
||||
then
|
||||
cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt" \grep -v instal$)"
|
||||
fi
|
||||
while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${cmds}" -- "${cur}")
|
||||
}
|
||||
export __HOMEBREW_COMMANDS=${cmds}
|
||||
}
|
||||
|
||||
# compopt is only available in newer versions of bash
|
||||
__brew_complete_files() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user