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

@@ -11,22 +11,20 @@ if [[ "$OSTYPE" != 'darwin'* ]]; then
fi
# Make sure brew is installed
_command_exists brew || return 0
_bash_it_homebrew_check || return 0
BREW_PREFIX=${BREW_PREFIX:-$(brew --prefix)}
if [[ -r "$BREW_PREFIX"/etc/bash_completion.d/brew ]]; then
if [[ -r "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew" ]]; then
# shellcheck disable=1090
source "$BREW_PREFIX"/etc/bash_completion.d/brew
source "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew"
elif [[ -r "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh ]]; then
elif [[ -r "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh" ]]; then
# shellcheck disable=1090
source "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh
source "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh"
elif [[ -f "$BREW_PREFIX"/completions/bash/brew ]]; then
elif [[ -f "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew" ]]; then
# For the git-clone based installation, see here for more info:
# https://github.com/Bash-it/bash-it/issues/1458
# https://docs.brew.sh/Shell-Completion
# shellcheck disable=1090
source "$BREW_PREFIX"/completions/bash/brew
source "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew"
fi