From a8c7e6f1ab53cc17df00ce643c571928223ae92b Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 21 Feb 2012 15:52:20 -0500 Subject: [PATCH] bash_aliases: fix prompt_ps1_git_branch() to work in a detached HEAD state --- bash_aliases | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash_aliases b/bash_aliases index 3e22bb3..7790672 100755 --- a/bash_aliases +++ b/bash_aliases @@ -41,7 +41,7 @@ function prompt_ps1_git_branch() if [[ "$branch_out" == "" ]]; then return 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/') if [[ "$ahead_behind" != "" ]]; then ahead_behind=": ${ahead_behind}"