lib/helpers: new function to set BASH_IT_HOMEBREW_PREFIX
New function `_bash_it_homebrew_check()` sets global variable `$BASH_IT_HOMEBREW_PREFIX` using `brew --prefix` if `brew` exists as a valid command. If `brew` isn't installed, then return failure. Plugins can test for `brew` by calling this function and, if it succeeds, they can rely on `$BASH_IT_HOMEBREW_PREFIX` being defined properly.pull/1910/head
parent
226454b069
commit
9e255c2139
|
|
@ -48,6 +48,19 @@ function _completion_exists ()
|
||||||
complete -p "$1" &> /dev/null && _log_warning "$msg" ;
|
complete -p "$1" &> /dev/null && _log_warning "$msg" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _bash_it_homebrew_check()
|
||||||
|
{
|
||||||
|
if [[ "${BASH_IT_HOMEBREW_PREFIX:-unset}" == 'unset' ]]
|
||||||
|
then # variable isn't set
|
||||||
|
if _binary_exists 'brew'
|
||||||
|
then # Homebrew is installed
|
||||||
|
BASH_IT_HOMEBREW_PREFIX="$(brew --prefix)"
|
||||||
|
else # Homebrew is not installed.
|
||||||
|
false # return failure if brew not installed.
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function _make_reload_alias() {
|
function _make_reload_alias() {
|
||||||
echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}"
|
echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue