Add git config option bash-it.hide-status to decide whether check git status.

This commit is contained in:
hequn
2014-04-02 18:41:28 +08:00
parent 51416056b2
commit 4eea1555aa

View File

@@ -73,10 +73,15 @@ function git_prompt_vars {
SCM_GIT_AHEAD=''
SCM_GIT_BEHIND=''
SCM_GIT_STASH=''
local status="$(git status -bs --porcelain 2> /dev/null)"
if [[ -n "$(grep -v ^# <<< "${status}")" ]]; then
SCM_DIRTY=1
SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
if [[ "$(git config --get bash-it.hide-status)" != "1" ]]; then
local status="$(git status -bs --porcelain 2> /dev/null)"
if [[ -n "$(grep -v ^# <<< "${status}")" ]]; then
SCM_DIRTY=1
SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
else
SCM_DIRTY=0
SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
fi
else
SCM_DIRTY=0
SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}