diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-25 11:24:23 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-25 11:24:23 +1200 |
commit | b86d2e14b4fed110c056b8d923129ef5a6364755 (patch) | |
tree | 69b484ce9edf8a4f77e07715892e70784dbbf227 /bash/bashrc.d/prompt.bash | |
parent | Remove Readline M-r for repeat command (diff) | |
download | dotfiles-b86d2e14b4fed110c056b8d923129ef5a6364755.tar.gz dotfiles-b86d2e14b4fed110c056b8d923129ef5a6364755.zip |
Show tag name in Git prompt if commit is tagged
Diffstat (limited to 'bash/bashrc.d/prompt.bash')
-rw-r--r-- | bash/bashrc.d/prompt.bash | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index ea2ba7f2..d981bccf 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -100,10 +100,12 @@ prompt() { [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) = true ]] || return - # Attempt to determine git branch, bail if we can't + # Find a branch label, or a tag, or just show the short commit ID, + # in that order of preference; if none of that works, bail out. local branch branch=$( { git symbolic-ref --quiet HEAD || + git describe --tags --exact-match HEAD || git rev-parse --short HEAD } 2>/dev/null ) [[ -n $branch ]] || return |