From b86d2e14b4fed110c056b8d923129ef5a6364755 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 25 Aug 2016 11:24:23 +1200 Subject: Show tag name in Git prompt if commit is tagged --- bash/bashrc.d/prompt.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bash') 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 -- cgit v1.2.3