Merge pull request #14527 from maxim-belkin/refix-bash-completions-1

Refix bash completions 1
This commit is contained in:
Mike McQuaid 2023-02-06 22:17:43 +01:00 committed by GitHub
commit ebed4f564d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 12 deletions

View File

@ -113,19 +113,25 @@ __brew_complete_tapped() {
} }
__brew_complete_commands() { __brew_complete_commands() {
# Auto-complete Homebrew commands
# Do NOT auto-complete "*instal" aliases for "*install" commands
local cur="${COMP_WORDS[COMP_CWORD]}" local cur="${COMP_WORDS[COMP_CWORD]}"
local cmds local cmds
HOMEBREW_CACHE=$(brew --cache)
HOMEBREW_REPOSITORY=$(brew --repo) if [[ -n ${__HOMEBREW_COMMANDS} ]]
# Do not auto-complete "*instal" or "*uninstal" aliases for "*install" commands. then
if [[ -f "${HOMEBREW_CACHE}/all_commands_list.txt" ]] cmds=${__HOMEBREW_COMMANDS}
elif [[ -n ${HOMEBREW_CACHE:-} && -f ${HOMEBREW_CACHE}/all_commands_list.txt ]]
then then
cmds="$(< "${HOMEBREW_CACHE}/all_commands_list.txt" \grep -v instal$)" 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$)" cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt" \grep -v instal$)"
fi fi
while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${cmds}" -- "${cur}") 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 # compopt is only available in newer versions of bash
__brew_complete_files() { __brew_complete_files() {

View File

@ -100,19 +100,25 @@ __brew_complete_tapped() {
} }
__brew_complete_commands() { __brew_complete_commands() {
# Auto-complete Homebrew commands
# Do NOT auto-complete "*instal" aliases for "*install" commands
local cur="${COMP_WORDS[COMP_CWORD]}" local cur="${COMP_WORDS[COMP_CWORD]}"
local cmds local cmds
HOMEBREW_CACHE=$(brew --cache)
HOMEBREW_REPOSITORY=$(brew --repo) if [[ -n ${__HOMEBREW_COMMANDS} ]]
# Do not auto-complete "*instal" or "*uninstal" aliases for "*install" commands. then
if [[ -f "${HOMEBREW_CACHE}/all_commands_list.txt" ]] cmds=${__HOMEBREW_COMMANDS}
elif [[ -n ${HOMEBREW_CACHE:-} && -f ${HOMEBREW_CACHE}/all_commands_list.txt ]]
then then
cmds="$(< "${HOMEBREW_CACHE}/all_commands_list.txt" \grep -v instal$)" 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$)" cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt" \grep -v instal$)"
fi fi
while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${cmds}" -- "${cur}") 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 # compopt is only available in newer versions of bash
__brew_complete_files() { __brew_complete_files() {