mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Merge c26323abd4 into 362927003b
This commit is contained in:
commit
db21df1610
2 changed files with 13 additions and 2 deletions
11
lib/git.zsh
11
lib/git.zsh
|
|
@ -1,7 +1,7 @@
|
||||||
# get the name of the branch we are on
|
# get the name of the branch we are on
|
||||||
function git_prompt_info() {
|
function git_prompt_info() {
|
||||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$(parse_git_stash)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Checks if working tree is dirty
|
# Checks if working tree is dirty
|
||||||
|
|
@ -13,6 +13,15 @@ parse_git_dirty() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Checks if working tree has stash
|
||||||
|
parse_git_stash() {
|
||||||
|
if [[ -n $(git stash list 2> /dev/null) ]]; then
|
||||||
|
echo "$ZSH_THEME_GIT_PROMPT_STASH"
|
||||||
|
else
|
||||||
|
echo "$ZSH_THEME_GIT_PROMPT_NOSTASH"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Checks if there are commits ahead from remote
|
# Checks if there are commits ahead from remote
|
||||||
function git_prompt_ahead() {
|
function git_prompt_ahead() {
|
||||||
if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
|
if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of th
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt
|
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt
|
||||||
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
|
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
|
||||||
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
|
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
|
||||||
|
ZSH_THEME_GIT_PROMPT_STASH="#" # Text to display if stash exists
|
||||||
|
ZSH_THEME_GIT_PROMPT_NOSTASH="" # Text to display if no stash exists
|
||||||
|
|
||||||
# Setup the prompt with pretty colors
|
# Setup the prompt with pretty colors
|
||||||
setopt prompt_subst
|
setopt prompt_subst
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue