From 6ffbce0f483c6b75f6bb0d7ddf48dad7ab494946 Mon Sep 17 00:00:00 2001 From: Bernardo Heynemann Date: Fri, 23 Sep 2016 16:53:47 -0300 Subject: [PATCH 1/2] Latest tag support --- fish_prompt.fish | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 1d311893..7b5c6ba0 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -20,6 +20,7 @@ # set -g theme_display_git no # set -g theme_display_git_untracked no # set -g theme_display_git_ahead_verbose yes +# set -g theme_display_git_latest_tag no # set -g theme_git_worktree_support yes # set -g theme_display_vagrant yes # set -g theme_display_docker_machine no @@ -51,16 +52,23 @@ # end function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish)' + if [ "$theme_display_git_latest_tag" = 'yes' ] + set -l latest_tag_value (command git for-each-ref --sort committerdate --format '%(refname)' refs/tags | sed s#refs/tags/## | tr -d ' ' | tail -1) + if [ "$latest_tag_value" != '' ] + set latest_tag " $__bobthefish_latest_tag_glyph$latest_tag_value" + end + end + set -l ref (command git symbolic-ref HEAD ^/dev/null) - and echo $ref | sed "s#refs/heads/#$__bobthefish_branch_glyph #" + and echo "$ref$latest_tag" | 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 echo "$__bobthefish_tag_glyph $tag$latest_tag" and return set -l branch (command git show-ref --head -s --abbrev | head -n1 ^/dev/null) - echo "$__bobthefish_detached_glyph $branch" + echo "$__bobthefish_detached_glyph $branch$latest_tag" end function __bobthefish_hg_branch -S -d 'Get the current hg branch' @@ -762,6 +770,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' # Additional glyphs set -l __bobthefish_detached_glyph \u27A6 set -l __bobthefish_tag_glyph \u2302 + set -l __bobthefish_latest_tag_glyph \u205D set -l __bobthefish_nonzero_exit_glyph '! ' set -l __bobthefish_superuser_glyph '$ ' set -l __bobthefish_bg_job_glyph '% ' From 4044c8515a68938bc9b38f0c482739248293f7ff Mon Sep 17 00:00:00 2001 From: Bernardo Heynemann Date: Fri, 23 Sep 2016 17:06:48 -0300 Subject: [PATCH 2/2] Improved getting latest tag --- fish_prompt.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 7b5c6ba0..ff018095 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -53,7 +53,7 @@ function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish)' if [ "$theme_display_git_latest_tag" = 'yes' ] - set -l latest_tag_value (command git for-each-ref --sort committerdate --format '%(refname)' refs/tags | sed s#refs/tags/## | tr -d ' ' | tail -1) + set -l latest_tag_value (command git describe --abbrev=0 --tags 2> /dev/null) if [ "$latest_tag_value" != '' ] set latest_tag " $__bobthefish_latest_tag_glyph$latest_tag_value" end