fix(brew): do not assume brew install path

This commit is contained in:
Gregor Bückendorf 2023-02-20 11:31:44 +01:00
parent 4a860bc607
commit a573d8f35b
2 changed files with 10 additions and 5 deletions

View file

@ -1,13 +1,17 @@
# Save other operating systems some work
if [[ $OSTYPE != darwin* ]]; then
if [[ $OSTYPE != darwin* ]] || ! command -v brew >/dev/null 2>&1; then
return
fi
BREW_DIR=$(brew --prefix)
# for brew formula bash-completion@2
if [[ -r /usr/local/etc/profile.d/bash_completion.sh ]]; then
export BASH_COMPLETION_COMPAT_DIR=/usr/local/etc/bash_completion.d
. /usr/local/etc/profile.d/bash_completion.sh
if [[ -r ${BREW_DIR}/etc/profile.d/bash_completion.sh ]]; then
export BASH_COMPLETION_COMPAT_DIR=${BREW_DIR}/etc/bash_completion.d
. ${BREW_DIR}/etc/profile.d/bash_completion.sh
fi
# for brew formula python
export PATH=/usr/local/opt/python/libexec/bin:$PATH
if [[ -d ${BREW_DIR}/opt/python/libexec/bin ]]; then
export PATH=${BREW_DIR}/opt/python/libexec/bin:$PATH
fi

View file

@ -18,6 +18,7 @@ possible_locations=(
"/usr/share/git/completion/git-completion.bash"
"/usr/share/bash-completion/completions/git"
"/usr/local/etc/bash_completion.d/git-completion.bash"
"/opt/homebrew/etc/bash_completion.d/git-completion.bash"
)
for completion_file in "${possible_locations[@]}"