Update way to get branch name in git repo.

This commit is contained in:
Darren 'Tadgy' Austin 2023-10-19 15:43:54 +01:00
commit c6cc2f3160

View file

@ -55,11 +55,12 @@ __prompt_git_status() {
}
# Add the branch or a no commits marker.
BRANCH="$(git describe --contains --all HEAD 2>/dev/null)"
if [[ -n "$BRANCH" ]]; then
GIT_PROMPT+="$BRANCH"
else
BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"
if [[ "$BRANCH" == "HEAD" ]]; then
GIT_PROMPT+="!NO COMMITS!"
unset BRANCH
else
GIT_PROMPT+="$BRANCH"
fi
# Add upstream status.