From 8be98c24b554aef178593f91e32ecac960ffa4dd Mon Sep 17 00:00:00 2001 From: chuang wang Date: Sun, 26 Dec 2021 08:52:01 +0800 Subject: [PATCH] feat(lib): add the git tag in the prompt Signed-off-by: chuang wang --- lib/git.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/git.zsh b/lib/git.zsh index be9fa7e67..c0b712845 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -22,6 +22,10 @@ function git_prompt_info() { || ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \ || return 0 + local tag + tag=$(__git_prompt_git describe --tags --exact-match 2> /dev/null) \ + && tag="(${tag})" + # Use global ZSH_THEME_GIT_SHOW_UPSTREAM=1 for including upstream remote info local upstream if (( ${+ZSH_THEME_GIT_SHOW_UPSTREAM} )); then @@ -29,7 +33,7 @@ function git_prompt_info() { && upstream=" -> ${upstream}" fi - echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" + echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${tag}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" } # Checks if working tree is dirty