bash_aliases: fix prompt_ps1_git_branch() to work in a detached HEAD state

This commit is contained in:
Josh Holtrop 2012-02-21 15:52:20 -05:00
parent 13b1427e11
commit a8c7e6f1ab

View File

@ -41,7 +41,7 @@ function prompt_ps1_git_branch()
if [[ "$branch_out" == "" ]]; then if [[ "$branch_out" == "" ]]; then
return return
fi fi
current_branch=$(echo "$branch_out" | awk '{print $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)' | sed -re 's/^.*(ahead|behind)(.[0-9]+).*$/\1\2/')
if [[ "$ahead_behind" != "" ]]; then if [[ "$ahead_behind" != "" ]]; then
ahead_behind=": ${ahead_behind}" ahead_behind=": ${ahead_behind}"