mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-05 01:46:46 +01:00
Improve the git prompt.
This commit is contained in:
parent
aa15f1b4d4
commit
3d22ee248c
2 changed files with 13 additions and 4 deletions
16
lib/git.zsh
16
lib/git.zsh
|
|
@ -5,10 +5,18 @@ function git_prompt_info() {
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_git_dirty () {
|
parse_git_dirty () {
|
||||||
if [[ $((git status 2> /dev/null) | tail -n1) != "nothing to commit (working directory clean)" ]]; then
|
gitstat=$(git status 2>/dev/null | grep '\(# Untracked\|# Changes\|# Changed but not updated:\)')
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
|
||||||
else
|
if [[ $(echo ${gitstat} | grep -c "^# Changes to be committed:$") > 0 ]]; then
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
echo -n "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $(echo ${gitstat} | grep -c "^\(# Untracked files:\|# Changed but not updated:\)$") > 0 ]]; then
|
||||||
|
echo -n "$ZSH_THEME_GIT_PROMPT_UNTRACKED"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $(echo ${gitstat} | wc -l | tr -d ' ') == 0 ]]; then
|
||||||
|
echo -n "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,4 +33,5 @@ RPROMPT='$(battery_charge)'
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
|
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
||||||
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"
|
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"
|
||||||
|
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
|
||||||
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue