prompt_ps1_git_branch: fix in case the words "ahead" or "behind" are in the commit comment

This commit is contained in:
Josh Holtrop 2013-07-02 16:51:46 -04:00
parent b9a7e85e0a
commit 1fcacd340e

View File

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