From d3b8edfacab5fcff79e37af6309a877e3305624f Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 29 Jun 2016 15:06:00 -0400 Subject: [PATCH] fix prompt_ps1_git_branch when non-active branches are ahead/behind --- bash_aliases | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bash_aliases b/bash_aliases index 6c54170..9327011 100755 --- a/bash_aliases +++ b/bash_aliases @@ -25,11 +25,12 @@ function prompt_ps1_git_branch() while read -r git_branch_out_line; do if [[ "$git_branch_out_line" =~ $re ]]; then local current_branch="${BASH_REMATCH[2]:-${BASH_REMATCH[3]}}" - re="((ahead|behind)[^]]*)\\]" - if [[ "$git_branch_out" =~ $re ]]; then + local re2="((ahead|behind)[^]]*)\\]" + if [[ "$git_branch_out_line" =~ $re2 ]]; then current_branch="$current_branch: ${BASH_REMATCH[1]}" fi echo " [${current_branch}${ahead_behind}]" + break fi done <<< "$git_branch_out" fi