fix: when in git directory and not in a branch, show (no branch)

This commit is contained in:
Eder Ruiz Maria 2012-10-13 21:45:01 -04:00
commit 99fc183e3d

View file

@ -1,7 +1,10 @@
# get the name of the branch we are on
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
if ! git status &> /dev/null; then
return
fi
branch=$(git branch | grep ^\* | cut -d" " -f2-)
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${branch}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}