Move common code to 2 branches of an 'if' out of it

Still optimizing EUID...
This commit is contained in:
Olivier Mengué 2013-06-11 22:37:14 +02:00
parent cc839487ec
commit aad57e8497

View File

@ -1523,19 +1523,18 @@ _lp_set_prompt()
# add user, host and permissions colon # add user, host and permissions colon
PS1="${PS1}${LP_BRACKET_OPEN}${LP_USER}${LP_HOST}${LP_PERM}" PS1="${PS1}${LP_BRACKET_OPEN}${LP_USER}${LP_HOST}${LP_PERM}"
PS1="${PS1}${LP_PWD}${LP_BRACKET_CLOSE}${LP_VENV}${LP_PROXY}"
# if not root # if not root
if [[ "$EUID" -ne "0" ]] if [[ "$EUID" -ne "0" ]]
then then
# path in foreground color
PS1="${PS1}${LP_PWD}${LP_BRACKET_CLOSE}${LP_VENV}${LP_PROXY}"
# add VCS infos # add VCS infos
PS1="${PS1}${LP_VCS}" PS1="${PS1}${LP_VCS}"
else else
# path in yellow
PS1="${PS1}${LP_PWD}${LP_BRACKET_CLOSE}${LP_VENV}${LP_PROXY}"
# do not add VCS infos unless told otherwise (LP_ENABLE_VCS_ROOT) # do not add VCS infos unless told otherwise (LP_ENABLE_VCS_ROOT)
[[ "$LP_ENABLE_VCS_ROOT" = "1" ]] && PS1="${PS1}${LP_VCS}" [[ "$LP_ENABLE_VCS_ROOT" = "1" ]] && PS1="${PS1}${LP_VCS}"
fi fi
# add return code and prompt mark # add return code and prompt mark
PS1="${PS1}${LP_ERR}${LP_MARK}${LP_PS1_POSTFIX}" PS1="${PS1}${LP_ERR}${LP_MARK}${LP_PS1_POSTFIX}"