From 59a98addb4fedd9da818bc81b16318f470feb7dc Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Tue, 22 Sep 2020 11:04:07 +0200 Subject: [PATCH] More robust parsing of branch name --- yashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yashrc b/yashrc index da91b41..2d4931c 100644 --- a/yashrc +++ b/yashrc @@ -20,7 +20,7 @@ ks() { s="$?" ; $* ; return "$s" ; } prompt_git() { porcelain="$(git status --branch --porcelain 2>/dev/null)" if test "$?" = 0; then - local branch="$(printf '%s' "$porcelain" | sed -n '1s/## \([^.]*\)\.\.\..*/\1/p')" + local branch="$(printf '%s' "$porcelain" | sed -n 's/\.\.\..*//;1s/## //p')" local behind="$(printf '%s' "$porcelain" | sed -n '1s/## .*behind \([0-9]*\).*/⇃\1/p')" local ahead="$(printf '%s' "$porcelain" | sed -n '1s/## .*ahead \([0-9]*\).*/↿\1/p')" local status="$({ echo OK; printf '%s' "$porcelain" | sed '/##/d;s/\(..\).*/\1/'; } | tail -1)"