]> git.alrj.org Git - zsh.d.git/blobdiff - S60_git
Rework the prompt config.
[zsh.d.git] / S60_git
diff --git a/S60_git b/S60_git
index 2972c391444caa3727df116269b7b3969959cee8..256afc8c08ec9951e9cb3c1abfd52ad442937ea2 100644 (file)
--- a/S60_git
+++ b/S60_git
@@ -1,10 +1,12 @@
 #! /usr/bin/zsh
 
+# Those can be used, for instance to construct the prompt:
 __ZSH_GIT_BASEDIR=""
 __ZSH_GIT_SUBDIR=""
 __ZSH_GIT_BRANCH=""
 __ZSH_GIT_ACTION=""
 __ZSH_GIT_STATUS=""
+
 __ZSH_GIT_VARS_INVALID=1
 __ZSH_GIT_STATUS_INVALID=1
 
@@ -59,40 +61,16 @@ git_get_status() {
 
 
 git_parse() {
-    # psvar[5] == current action (merge, rebase, ...)
-    # psvar[6] == current branch
-    # psvar[7] == repository base directory
-    # psvar[8] == current subdir into repository
-    # psvar[9] == status (untracked, unstaged, staged)
-
     local git_dir ref base_dir sub_dir action branch gitstat gitstatus
 
-
     # If nothing has been invalidated
     if [[ "${__ZSH_GIT_VARS_INVALID}" == "0" && "${__ZSH_GIT_STATUS_INVALID}" == "0" ]]; then
-
-      # reuse previous values
-      psvar[5]=${__ZSH_GIT_ACTION}
-      psvar[6]=${__ZSH_GIT_BRANCH}
-      psvar[7]=${__ZSH_GIT_BASEDIR}
-      psvar[8]=${__ZSH_GIT_SUBDIR}
-      psvar[9]=${__ZSH_GIT_STATUS}
-
       return
     fi
 
     # If only status has been invalidated
     if [[ "${__ZSH_GIT_VARS_INVALID}" == "0" && "${__ZSH_GIT_STATUS_INVALID}" == "1" ]]; then
-
-      # reuse previous values
-      psvar[5]=${__ZSH_GIT_ACTION}
-      psvar[6]=${__ZSH_GIT_BRANCH}
-      psvar[7]=${__ZSH_GIT_BASEDIR}
-      psvar[8]=${__ZSH_GIT_SUBDIR}
-
       __ZSH_GIT_STATUS=$(git_get_status)
-      psvar[9]=${__ZSH_GIT_STATUS}
-
       __ZSH_GIT_STATUS_INVALID=0
       return
     fi
@@ -134,28 +112,18 @@ git_parse() {
       action="-merge"
       branch="$ref"
     else
-      test -f "$git_dir/BISECT_LOG" && psvar[3]="bisect"
+      test -f "$git_dir/BISECT_LOG" && action="-bisect"
       branch="$(git symbolic-ref HEAD 2>/dev/null)" || \
         branch="$(git describe --exact-match HEAD 2>/dev/null)" || \
         branch="$(cut -c1-7 "$git_dir/HEAD")..."
     fi
 
-    # Status
-    gitstatus=`git_get_status`
-
-    # Got here, we're in git
-    psvar[5]=${action}
-    psvar[6]=${branch#refs/heads/}
-    psvar[7]=${base_dir}
-    psvar[8]=${sub_dir}
-    psvar[9]=${gitstatus}
-    
-    # Save for next time
+
     __ZSH_GIT_BASEDIR="${base_dir}"
     __ZSH_GIT_SUBDIR="${sub_dir}"
     __ZSH_GIT_BRANCH="${branch#refs/heads/}"
     __ZSH_GIT_ACTION="${action}"
-    __ZSH_GIT_STATUS="${gitstatus}"
+    __ZSH_GIT_STATUS=`git_get_status`
 
     __ZSH_GIT_VARS_INVALID=0
     __ZSH_GIT_STATUS_INVALID=0