summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <erich.eckner.ext@bestsecret.com>2024-07-18 07:57:48 +0200
committerErich Eckner <erich.eckner.ext@bestsecret.com>2024-07-18 07:57:48 +0200
commitba94d8601c1d71582aea2e64a6986b4245a4ba94 (patch)
treeb6179df258907e91ba6589d55c5a48e38b855526
parent30203a705e3ce3d5d549ef7ae5d1fba308cab815 (diff)
downloadbash-git-prompt-ba94d8601c1d71582aea2e64a6986b4245a4ba94.tar.xz
bash-git-prompt: better branch parsing for branches containing "/"
-rwxr-xr-xbash-git-prompt.in12
1 files changed, 11 insertions, 1 deletions
diff --git a/bash-git-prompt.in b/bash-git-prompt.in
index 14640b9..e67d6dd 100755
--- a/bash-git-prompt.in
+++ b/bash-git-prompt.in
@@ -40,7 +40,17 @@ fi
if ! ${skip} && status=$(git status --porcelain 2> /dev/null)
then
[ -n "${PS1}" ] && PS1="$PS1 "
- branch="$((git symbolic-ref HEAD 2> /dev/null || git describe --always) | sed "s|^.*/||")"
+ branch=$(
+ (
+ git symbolic-ref HEAD 2> /dev/null \
+ || git describe --always
+ ) \
+ | sed '
+ s|^refs/heads/||
+ t
+ s|^.*/||
+ '
+ )
gitDir="$(git rev-parse --show-toplevel)/$(git rev-parse --git-dir)"
if [ -e ${gitDir}/rebase-merge ] || [ -e ${gitDir}/rebase-apply ]
then