]> git.alrj.org Git - zsh.d.git/blobdiff - S60_git
Slight change to git prompt
[zsh.d.git] / S60_git
diff --git a/S60_git b/S60_git
index 54e61d477ad110bc101814a157c7fdf88db7c995..2972c391444caa3727df116269b7b3969959cee8 100644 (file)
--- a/S60_git
+++ b/S60_git
@@ -27,24 +27,31 @@ git_preexec() {
   __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:\)')
+    # 'fix for mcedit parser
     gitstatus=""
 
     if [[ $(echo ${gitstat} | grep -c "^# Changes to be committed:$") > 0 ]]; then
-      gitstatus='+'
+      gitstatus=''
     fi
 
-    if [[ $(echo ${gitstat} | grep -c "^\# Changed but not updated:$") > 0 ]]; then
-      gitstatus="${gitstatus}!"
+    if [[ $(echo ${gitstat} | grep -c "^\# Changed but not updated:$") > 0 || \
+          $(echo ${gitstat} | grep -c "^\# Changes not staged for commit:$") > 0 ]]; then
+      gitstatus="${gitstatus}✹"
     fi
 
     if [[ $(echo ${gitstat} | grep -c "^# Untracked files:$") > 0 ]]; then
-      gitstatus="${gitstatus}?"
+      gitstatus="${gitstatus}★"
+    fi
+
+    if [[ -z $gitstatus ]]; then
+      gitstatus="%{${fg_bold[green]}%}✔%{$reset_color%}"
+    else
+      gitstatus="%{${fg_bold[yellow]}%}$gitstatus%{$reset_color%}"
     fi
 
     echo $gitstatus
@@ -95,10 +102,15 @@ git_parse() {
 
     git_dir=$(git rev-parse --git-dir 2> /dev/null) || return
 
-    base_dir=${$(readlink -f "$git_dir/..")/$HOME/'~'}
+    if [[ "$(git rev-parse --is-bare-repository)" == "true" ]]; then
+      base_dir=${$(readlink -f "$git_dir")/$HOME/'~'}
+      sub_dir=${$(pwd)#$(readlink -f "$git_dir")}
+    else
+      base_dir=${$(readlink -f "$git_dir/..")/$HOME/'~'}
+      sub_dir=${$(pwd)#$(readlink -f "$git_dir/..")}
+    fi
 
-    sub_dir=$(git rev-parse --show-prefix)
-    sub_dir=${sub_dir%/}
+    sub_dir=${sub_dir#/}
     ref=$(git symbolic-ref HEAD 2> /dev/null) || return
 
     action=""