X-Git-Url: https://git.madduck.net/etc/zsh.git/blobdiff_plain/bfce2547c1f318bd9b683fa24551e086f8112aad..f141cb2977c8c2aa8135796863bcb373784f6fc3:/.zsh/zshrc/85_vcs_prompt?ds=inline diff --git a/.zsh/zshrc/85_vcs_prompt b/.zsh/zshrc/85_vcs_prompt index 81e7773..814fed8 100644 --- a/.zsh/zshrc/85_vcs_prompt +++ b/.zsh/zshrc/85_vcs_prompt @@ -52,19 +52,24 @@ __get_prompt_path_components() __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 CVS ] && echo cvs && break + [ "$PWD" = / ] && echo NONE && return 1 + cd .. + done } __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") @@ -76,6 +81,10 @@ __vcs_set_prompt_variables() 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