lib/theme: new _bash_it_appearance_scm_init()
Wrap init code in a function and call the function immediately. Several plugins do this, and it allows us to more easily implement a hooks-based system in the future. Alsö, avoid external binary `which`. Use built-in `type -P` instead. Uppercase `-P` forces a path search to avoid hashed matches and functions/aliases and whatnot.
This commit is contained in:
@@ -85,19 +85,27 @@ RBENV_THEME_PROMPT_SUFFIX='|'
|
||||
RBFU_THEME_PROMPT_PREFIX=' |'
|
||||
RBFU_THEME_PROMPT_SUFFIX='|'
|
||||
|
||||
GIT_EXE=$(which git 2> /dev/null || true)
|
||||
P4_EXE=$(which p4 2> /dev/null || true)
|
||||
HG_EXE=$(which hg 2> /dev/null || true)
|
||||
SVN_EXE=$(which svn 2> /dev/null || true)
|
||||
: "${GIT_EXE:=$SCM_GIT}"
|
||||
: "${P4_EXE:=$SCM_P4}"
|
||||
: "${HG_EXE:=$SCM_HG}"
|
||||
: "${SVN_EXE:=$SCM_SVN}"
|
||||
|
||||
# Check for broken SVN exe that is caused by some versions of Xcode.
|
||||
# See https://github.com/Bash-it/bash-it/issues/1612 for more details.
|
||||
if [[ -x "$SVN_EXE" && -x "${SVN_EXE%/*}/xcrun" ]]; then
|
||||
if ! "$SVN_EXE" --version > /dev/null 2>&1; then
|
||||
# Unset the SVN exe variable so that SVN commands are avoided.
|
||||
SVN_EXE=""
|
||||
function _bash_it_appearance_scm_init() {
|
||||
GIT_EXE="$(type -P $SCM_GIT || true)"
|
||||
P4_EXE="$(type -P $SCM_P4 || true)"
|
||||
HG_EXE="$(type -P $SCM_HG || true)"
|
||||
SVN_EXE="$(type -P $SCM_SVN || true)"
|
||||
|
||||
# Check for broken SVN exe that is caused by some versions of Xcode.
|
||||
# See https://github.com/Bash-it/bash-it/issues/1612 for more details.
|
||||
if [[ -x "$SVN_EXE" && -x "${SVN_EXE%/*}/xcrun" ]]; then
|
||||
if ! "$SVN_EXE" --version > /dev/null 2>&1; then
|
||||
# Unset the SVN exe variable so that SVN commands are avoided.
|
||||
SVN_EXE=""
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
_bash_it_appearance_scm_init
|
||||
|
||||
function scm {
|
||||
if [[ "$SCM_CHECK" = false ]]; then
|
||||
|
||||
Reference in New Issue
Block a user