]> gitweb @ CieloNegro.org - sugar.git/blobdiff - dot-files/_zshrc
Auto commit by The Sugar System.
[sugar.git] / dot-files / _zshrc
index d5fdcf850a7e95ae29ad3f515e6487a6559e4372..eaf76574fb788c92b3d7c704bc9e078b9b424d96 100644 (file)
@@ -75,7 +75,7 @@ function preexec() { # Hook
 }
 
 function chpwd() { # Hook
-    local dirinfo=$(print_directory_info)
+    local dirinfo=$(print_directory_info $(pwd))
 
     case $dirinfo in
         "")
@@ -86,40 +86,29 @@ function chpwd() { # Hook
 }
 
 function print_directory_info() {
-    local vcs_type=$(print_vcs_type $(pwd))
-
-    case $vcs_type in
-        git)
-            git branch --no-color 2>/dev/null \
-                | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/';;
-        hg)
-            hg branch 2>/dev/null;;
-        darcs-*)
-            # Delete `darcs-' at the beginning.
-            echo ${vcs_type#darcs-};;
-        *)
-            # Unknown
-            echo
-    esac
-}
-
-function print_vcs_type() {
     local absdir=$1
 
     if [[ -d $absdir/.git ]] then
-        echo git
+        # Git
+        git branch --no-color 2>/dev/null \
+            | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
+
     elif [[ -d $absdir/.hg ]] then
-        echo hg
+        # Hg
+        hg branch 2>/dev/null
+
     elif [[ -d $absdir/_darcs ]] then
-        echo darcs-$(basename $absdir)
+        # Darcs
+        basename $absdir
+
     else
-        # Nothing.
+        # Unknown.
         if [[ $absdir = "/" ]] then
             # This is the root directory so exit from the recursion.
             echo
         else
             # Recurse to the parent dir.
-            print_vcs_type $(dirname $absdir)
+            print_directory_info $(dirname $absdir)
         fi
     fi
 }