1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-23 14:20:08 +00:00

feat(lib): add the git tag in the prompt

Signed-off-by: chuang wang <nashuiliang@gmail.com>
This commit is contained in:
chuang wang 2021-12-26 08:52:01 +08:00
parent 2d3bae965a
commit 8be98c24b5

View file

@ -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