Git-related fixes for themes.

Improved prompt display speed when git is not installed by
preventing bash from walking the path before each prompt.

Removed pesky stash-related git error message when in bare repos.
pull/275/head
Christophe Aguettaz 2014-03-15 11:38:25 +01:00
parent 714f0e6099
commit c06ecc53cb
1 changed files with 2 additions and 2 deletions

View File

@ -32,7 +32,7 @@ RBFU_THEME_PROMPT_SUFFIX='|'
function scm { function scm {
if [[ -f .git/HEAD ]]; then SCM=$SCM_GIT if [[ -f .git/HEAD ]]; then SCM=$SCM_GIT
elif [[ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]]; then SCM=$SCM_GIT elif which git &> /dev/null && [[ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]]; then SCM=$SCM_GIT
elif [[ -d .hg ]]; then SCM=$SCM_HG elif [[ -d .hg ]]; then SCM=$SCM_HG
elif which hg &> /dev/null && [[ -n "$(hg root 2> /dev/null)" ]]; then SCM=$SCM_HG elif which hg &> /dev/null && [[ -n "$(hg root 2> /dev/null)" ]]; then SCM=$SCM_HG
elif [[ -d .svn ]]; then SCM=$SCM_SVN elif [[ -d .svn ]]; then SCM=$SCM_SVN
@ -90,7 +90,7 @@ function git_prompt_vars {
local behind_re='.+behind ([0-9]+).+' local behind_re='.+behind ([0-9]+).+'
[[ "${status}" =~ ${ahead_re} ]] && SCM_GIT_AHEAD=" ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}" [[ "${status}" =~ ${ahead_re} ]] && SCM_GIT_AHEAD=" ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}"
[[ "${status}" =~ ${behind_re} ]] && SCM_GIT_BEHIND=" ${SCM_GIT_BEHIND_CHAR}${BASH_REMATCH[1]}" [[ "${status}" =~ ${behind_re} ]] && SCM_GIT_BEHIND=" ${SCM_GIT_BEHIND_CHAR}${BASH_REMATCH[1]}"
local stash_count="$(git stash list | wc -l | tr -d ' ')" local stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
[[ "${stash_count}" -gt 0 ]] && SCM_GIT_STASH=" {${stash_count}}" [[ "${stash_count}" -gt 0 ]] && SCM_GIT_STASH=" {${stash_count}}"
} }