Permalink
Browse files

Improve the git prompt.

  • Loading branch information...
1 parent aa15f1b commit 3d22ee248c6bce357c018a93d31f8d292d2cb4cd Steve Losh committed Jan 20, 2010
Showing with 13 additions and 4 deletions.
  1. +12 −4 lib/git.zsh
  2. +1 −0 themes/prose.zsh-theme
View
@@ -5,10 +5,18 @@ function git_prompt_info() {
}
parse_git_dirty () {
- if [[ $((git status 2> /dev/null) | tail -n1) != "nothing to commit (working directory clean)" ]]; then
- echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
- else
- echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
+ gitstat=$(git status 2>/dev/null | grep '\(# Untracked\|# Changes\|# Changed but not updated:\)')
+
+ if [[ $(echo ${gitstat} | grep -c "^# Changes to be committed:$") > 0 ]]; then
+ 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
}
@@ -33,4 +33,5 @@ RPROMPT='$(battery_charge)'
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"
+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
ZSH_THEME_GIT_PROMPT_CLEAN=""

0 comments on commit 3d22ee2

Please sign in to comment.