Merge pull request #181 from dolmen/optimize/_lp_are_vcs_disabled

Optimize _lp_are_vcs_disabled
This commit is contained in:
nojhan 2013-05-22 11:38:07 -07:00
commit 71466d8636

View File

@ -668,18 +668,15 @@ _lp_return_value()
# VCS branch display # # VCS branch display #
###################### ######################
_lp_are_vcs_disabled() _lp_are_vcs_enabled()
{ {
[[ -z "$LP_DISABLED_VCS_PATH" ]] && echo 0 && return [[ -z "$LP_DISABLED_VCS_PATH" ]] && return 0
local path local path
local IFS=: local IFS=:
for path in $LP_DISABLED_VCS_PATH; do for path in $LP_DISABLED_VCS_PATH; do
if [[ "$PWD" == *"$path"* ]]; then [[ "$PWD" == *"$path"* ]] && return 1
echo 1
return
fi
done done
echo 0 return 0
} }
# GIT # # GIT #
@ -1428,16 +1425,15 @@ _lp_set_prompt()
LP_PWD=$(_lp_shorten_path) LP_PWD=$(_lp_shorten_path)
[[ -n "$PROMPT_DIRTRIM" ]] && PROMPT_DIRTRIM=$(_lp_get_dirtrim) [[ -n "$PROMPT_DIRTRIM" ]] && PROMPT_DIRTRIM=$(_lp_get_dirtrim)
if [[ "$(_lp_are_vcs_disabled)" -eq "0" ]] ; then if _lp_are_vcs_enabled; then
LP_VCS="$(_lp_git_branch_color)" LP_VCS="$(_lp_git_branch_color)"
LP_VCS_TYPE="git" LP_VCS_TYPE="git"
if [[ -n "$LP_VCS" ]]; then if [[ -n "$LP_VCS" ]]; then
# If this is a git-svn repository # If this is a git-svn repository
if [[ -d "$(git rev-parse --git-dir 2>/dev/null)/svn" ]]; then if [[ -d "$(git rev-parse --git-dir 2>/dev/null)/svn" ]]; then
LP_VCS_TYPE="git-svn" LP_VCS_TYPE="git-svn"
fi fi # git-svn
fi # git-svn else
if [[ -z "$LP_VCS" ]]; then
LP_VCS="$(_lp_hg_branch_color)" LP_VCS="$(_lp_hg_branch_color)"
LP_VCS_TYPE="hg" LP_VCS_TYPE="hg"
if [[ -z "$LP_VCS" ]]; then if [[ -z "$LP_VCS" ]]; then