Update way to get branch name in git repo.
This commit is contained in:
parent
2b6d51aa5d
commit
c6cc2f3160
1 changed files with 5 additions and 4 deletions
9
.bashrc
9
.bashrc
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue