mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
feat(lib): add the git tag in the prompt
Signed-off-by: chuang wang <nashuiliang@gmail.com>
This commit is contained in:
parent
2d3bae965a
commit
8be98c24b5
1 changed files with 5 additions and 1 deletions
|
@ -22,6 +22,10 @@ function git_prompt_info() {
|
||||||
|| ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \
|
|| ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \
|
||||||
|| return 0
|
|| 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
|
# Use global ZSH_THEME_GIT_SHOW_UPSTREAM=1 for including upstream remote info
|
||||||
local upstream
|
local upstream
|
||||||
if (( ${+ZSH_THEME_GIT_SHOW_UPSTREAM} )); then
|
if (( ${+ZSH_THEME_GIT_SHOW_UPSTREAM} )); then
|
||||||
|
@ -29,7 +33,7 @@ function git_prompt_info() {
|
||||||
&& upstream=" -> ${upstream}"
|
&& upstream=" -> ${upstream}"
|
||||||
fi
|
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
|
# Checks if working tree is dirty
|
||||||
|
|
Loading…
Reference in a new issue