]> git.madduck.net Git - etc/zsh.git/blobdiff - .zsh/zshrc/85_vcs_prompt

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Add svk to detection routine
[etc/zsh.git] / .zsh / zshrc / 85_vcs_prompt
index c6b3c79c2a471780b8b5b8d3175dc569db33999b..e0fbbd017fd7402a117d382be21596d50b10819a 100644 (file)
@@ -52,19 +52,25 @@ __get_prompt_path_components()
 
 __vcs_get_repo_type()
 {
 
 __vcs_get_repo_type()
 {
-  if __git_get_repo_root >/dev/null; then
-    echo git
-  else
-    echo NONE
-  fi
+  while true; do
+    [ -d .git ] && echo git && break
+    [ -d .bzr ] && echo bzr && break
+    [ -d .hg ] && echo hg && break
+    [ -d .svn ] && echo svn && break
+    [ -d .svk ] && echo svk && break
+    [ -d CVS ] && echo cvs && break
+    [ "$PWD" = / ] && echo NONE && return 1
+    cd ..
+  done
 }
 
 __vcs_set_prompt_variables()
 {
   local pre branch post
   local MAXLEN=25
 }
 
 __vcs_set_prompt_variables()
 {
   local pre branch post
   local MAXLEN=25
+  local repotype="${1:-$(__vcs_get_repo_type)}"
 
 
-  case "${1:-$(__vcs_get_repo_type)}" in
+  case "$repotype" in
     git)
       local reporoot="$(__git_get_repo_root)"
       set -- $(__get_prompt_path_components "$reporoot")
     git)
       local reporoot="$(__git_get_repo_root)"
       set -- $(__get_prompt_path_components "$reporoot")
@@ -76,6 +82,10 @@ __vcs_set_prompt_variables()
       pre="${(%)pre}"
       ;;
     *)
       pre="${(%)pre}"
       ;;
     *)
+      case "$repotype" in
+        NONE) :;;
+        *) warn "$repotype repositories not (yet) supported in the prompt";;
+      esac
       local p="%${MAXLEN}<..<%~%<<"
       #TODO find a better way so we don't have to nuke $psvar, but since the
       #     %(nv.true.false) check for prompts checks element count, not
       local p="%${MAXLEN}<..<%~%<<"
       #TODO find a better way so we don't have to nuke $psvar, but since the
       #     %(nv.true.false) check for prompts checks element count, not
@@ -99,7 +109,7 @@ if ! is_root; then
       *${vcs}*) __vcs_set_prompt_variables
     esac
   }
       *${vcs}*) __vcs_set_prompt_variables
     esac
   }
-  precmd_functions+=_update_vcs prompt_vars_if_vcs_ran
+  precmd_functions+=_update_vcs_prompt_vars_if_vcs_ran
 
   _update_vcs_prompt_vars() {
     __vcs_set_prompt_variables
 
   _update_vcs_prompt_vars() {
     __vcs_set_prompt_variables