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

Update manpage and completions. #18866

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions completions/bash/brew
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ __brew_complete_commands() {

local cur="${COMP_WORDS[COMP_CWORD]}"
local cmds
local -a cmd_aliases

if [[ -n ${__HOMEBREW_COMMANDS} ]]
then
Expand All @@ -109,6 +110,8 @@ __brew_complete_commands() {
then
cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt")"
fi
while read -r alias; do cmd_aliases+=("${alias}"); done < <(compgen -W "$(__brew_list_aliases)")
[[ -n ${cmd_aliases[*]+"${cmd_aliases[*]}"} ]] && cmds+=" ${cmd_aliases[*]} alias unalias"
while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${cmds}" -- "${cur}")
export __HOMEBREW_COMMANDS=${cmds}
}
Expand All @@ -118,6 +121,26 @@ __brew_complete_files() {
command -v compopt &> /dev/null && compopt -o default
}

# https://github.com/Homebrew/homebrew-aliases
__brew_list_aliases() {
local aliases_dir="${HOME}/.brew-aliases"
local pattern="^# alias: brew ([[:alnum:]-]+)$"
local -a aliases

[[ ! -d ${aliases_dir} ]] && return

for file in "${aliases_dir}"/*; do
[[ ! -f ${file} ]] && continue
while read -r line; do
if [[ ${line} =~ ${pattern} ]]; then
aliases+=("${BASH_REMATCH[1]}")
break
fi
done < "${file}"
done
[[ -n ${aliases[*]+"${aliases[*]}"} ]] && echo "${aliases[@]}"
}

_brew___cache() {
local cur="${COMP_WORDS[COMP_CWORD]}"
case "${cur}" in
Expand Down
Loading