From 4669e3dad6ad1a811374cb318529c66546e55190 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Thu, 25 Aug 2016 08:01:08 -0700 Subject: [PATCH] Add better tag support in the git branch segment. --- fish_prompt.fish | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index f540561..1322c3e 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -52,11 +52,15 @@ function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish)' set -l ref (command git symbolic-ref HEAD ^/dev/null) - if [ $status -gt 0 ] - set -l branch (command git show-ref --head -s --abbrev | head -n1 ^/dev/null) - set ref "$__bobthefish_detached_glyph $branch" - end - echo $ref | sed "s#refs/heads/#$__bobthefish_branch_glyph #" + and echo $ref | sed "s#refs/heads/#$__bobthefish_branch_glyph #" + and return + + set -l tag (command git describe --tags --exact-match ^/dev/null) + and echo "$__bobthefish_tag_glyph $tag" + and return + + set -l branch (command git show-ref --head -s --abbrev | head -n1 ^/dev/null) + echo "$__bobthefish_detached_glyph $branch" end function __bobthefish_hg_branch -S -d 'Get the current hg branch'