prompt_ps1_git_branch: handle being both ahead and behind tracking branch

This commit is contained in:
Josh Holtrop 2013-07-02 16:49:22 -04:00
parent ac5e13e215
commit b9a7e85e0a

View File

@ -43,7 +43,7 @@ function prompt_ps1_git_branch()
return return
fi fi
current_branch=$(echo "$branch_out" | sed -re 's/(.no.branch.|[^ ]*).*/\1/') current_branch=$(echo "$branch_out" | sed -re 's/(.no.branch.|[^ ]*).*/\1/')
ahead_behind=$(echo "$branch_out" | grep -E '(ahead|behind)' | sed -re 's/^.*(ahead|behind)(.[0-9]+).*$/\1\2/') ahead_behind=$(echo "$branch_out" | grep -E '(ahead|behind)' | grep -Eo '(ahead|behind)[^]]*')
if [[ "$ahead_behind" != "" ]]; then if [[ "$ahead_behind" != "" ]]; then
ahead_behind=": ${ahead_behind}" ahead_behind=": ${ahead_behind}"
fi fi