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.pull/1910/head
parent
9e255c2139
commit
65ef8e2e8b
|
|
@ -11,22 +11,20 @@ if [[ "$OSTYPE" != 'darwin'* ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure brew is installed
|
# Make sure brew is installed
|
||||||
_command_exists brew || return 0
|
_bash_it_homebrew_check || return 0
|
||||||
|
|
||||||
BREW_PREFIX=${BREW_PREFIX:-$(brew --prefix)}
|
if [[ -r "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew" ]]; then
|
||||||
|
|
||||||
if [[ -r "$BREW_PREFIX"/etc/bash_completion.d/brew ]]; then
|
|
||||||
# shellcheck disable=1090
|
# 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
|
# 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:
|
# For the git-clone based installation, see here for more info:
|
||||||
# https://github.com/Bash-it/bash-it/issues/1458
|
# https://github.com/Bash-it/bash-it/issues/1458
|
||||||
# https://docs.brew.sh/Shell-Completion
|
# https://docs.brew.sh/Shell-Completion
|
||||||
# shellcheck disable=1090
|
# shellcheck disable=1090
|
||||||
source "$BREW_PREFIX"/completions/bash/brew
|
source "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,11 @@ elif [[ -r /etc/profile.d/bash_completion.sh ]] ; then
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
source /etc/profile.d/bash_completion.sh
|
source /etc/profile.d/bash_completion.sh
|
||||||
|
|
||||||
elif [[ $OSTYPE == 'darwin'* ]] && _command_exists brew ; then
|
elif _bash_it_homebrew_check
|
||||||
BREW_PREFIX=${BREW_PREFIX:-$(brew --prefix)}
|
then
|
||||||
|
|
||||||
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path
|
# 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
|
# shellcheck disable=SC1090
|
||||||
source "$BREW_PREFIX"/etc/bash_completion
|
source "$BASH_IT_HOMEBREW_PREFIX"/etc/profile.d/bash_completion.sh
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ about-plugin 'Autojump configuration, see https://github.com/wting/autojump for
|
||||||
|
|
||||||
# Only supports the Homebrew variant, Debian and Arch at the moment.
|
# Only supports the Homebrew variant, Debian and Arch at the moment.
|
||||||
# Feel free to provide a PR to support other install locations
|
# Feel free to provide a PR to support other install locations
|
||||||
if command -v brew &>/dev/null && [[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]]; then
|
if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" ]]; then
|
||||||
. $(brew --prefix)/etc/profile.d/autojump.sh
|
. "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh"
|
||||||
elif command -v dpkg &>/dev/null && dpkg -s autojump &>/dev/null ; then
|
elif command -v dpkg &>/dev/null && dpkg -s autojump &>/dev/null ; then
|
||||||
. "$(dpkg-query -S autojump.sh | cut -d' ' -f2)"
|
. "$(dpkg-query -S autojump.sh | cut -d' ' -f2)"
|
||||||
elif command -v pacman &>/dev/null && pacman -Q autojump &>/dev/null ; then
|
elif command -v pacman &>/dev/null && pacman -Q autojump &>/dev/null ; then
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ about-plugin 'node version manager configuration'
|
||||||
|
|
||||||
export NVM_DIR=${NVM_DIR:-$HOME/.nvm}
|
export NVM_DIR=${NVM_DIR:-$HOME/.nvm}
|
||||||
# This loads nvm
|
# This loads nvm
|
||||||
if command -v brew &>/dev/null && [ -s $(brew --prefix nvm)/nvm.sh ]
|
if _bash_it_homebrew_check && [ -s "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh" ]
|
||||||
then
|
then
|
||||||
. $(brew --prefix nvm)/nvm.sh
|
. "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh"
|
||||||
else
|
else
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue