Use _bash_it_homebrew_check() in plugins, completions

Use new function `_bash_it_homebrew_check()` in existing plugins and completions which look for Homebrew.

Alsö, use `$OSTYPE` instead of calling external `uname` binary.
This commit is contained in:
John D Pell
2021-08-11 18:05:20 -07:00
parent 9e255c2139
commit 65ef8e2e8b
4 changed files with 15 additions and 18 deletions

View File

@@ -14,12 +14,11 @@ elif [[ -r /etc/profile.d/bash_completion.sh ]] ; then
# shellcheck disable=SC1091
source /etc/profile.d/bash_completion.sh
elif [[ $OSTYPE == 'darwin'* ]] && _command_exists brew ; then
BREW_PREFIX=${BREW_PREFIX:-$(brew --prefix)}
elif _bash_it_homebrew_check
then
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path
if [[ -r "$BREW_PREFIX"/etc/bash_completion ]] ; then
if [[ -r "$BASH_IT_HOMEBREW_PREFIX"/etc/profile.d/bash_completion.sh ]] ; then
# shellcheck disable=SC1090
source "$BREW_PREFIX"/etc/bash_completion
source "$BASH_IT_HOMEBREW_PREFIX"/etc/profile.d/bash_completion.sh
fi
fi