+export __ZSH_GIT_STATUS_INVALID=1
+
+
+git_chpwd() {
+ # On cd, invalidate git status in prompt
+ export __ZSH_GIT_VARS_INVALID=1
+}
+
+
+git_preexec() {
+ # On git command, invalidate git status in prompt
+ case "$1" in
+ git*)
+ export __ZSH_GIT_VARS_INVALID=1
+ ;;
+ esac
+
+ # *any* command could invalidate the repository status (new file, ...)
+ export __ZSH_GIT_STATUS_INVALID=1
+}
+
+
+git_get_status() {
+ # Return only git status
+ local gitstat gitstatus
+
+ gitstat=$(git status 2> /dev/null | grep '\(# Untracked\|# Changes\|# Changed but not updated:\)')
+ gitstatus=""
+
+ if [[ $(echo ${gitstat} | grep -c "^# Changes to be committed:$") > 0 ]]; then
+ gitstatus='+'
+ fi
+
+ if [[ $(echo ${gitstat} | grep -c "^\# Changed but not updated:$") > 0 ]]; then
+ gitstatus="${gitstatus}!"
+ fi
+
+ if [[ $(echo ${gitstat} | grep -c "^# Untracked files:$") > 0 ]]; then
+ gitstatus="${gitstatus}?"
+ fi
+
+ echo $gitstatus
+}
+