zshrc: eliminate file access on precmd()
[shutils.git] / dotfiles / shell / zshrc
index 877798900e514ab6f400869bdd218fe2256f4f3c..cc00a537b9f712aa9dc7bfd17041c81b7ab39ea9 100644 (file)
@@ -25,6 +25,8 @@ eval `dircolors`
 LS_COLORS="${LS_COLORS}*.divx=01;35:"
 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
 
+TERM=xterm-256color
+
 zstyle ':completion:*' menu select
 zmodload -i zsh/complist
 
@@ -92,9 +94,9 @@ zstyle ':vcs_info:*' max-exports 1
 function setprompt()
 {
        # default: " (%s)-[%b|%a]%u%c-"
-       zstyle ':vcs_info:*' actionformats "${PR_YELLOW}%s:%b|%a${PR_NO_COLOUR} "
+       zstyle ':vcs_info:*' actionformats "${PR_YELLOW}%s:%b|%a${PR_NO_COLOUR}"
        # default: " (%s)-[%b]%u%c-"
-       zstyle ':vcs_info:*' formats       "${PR_YELLOW}%s:%b${PR_NO_COLOUR} "
+       zstyle ':vcs_info:*' formats       "${PR_YELLOW}%s:%b${PR_NO_COLOUR}"
 
        setopt PROMPT_SUBST
        PROMPT='%(!.$PR_RED.$PR_GREEN)%n@%m $PR_BLUE%1~ %# $PR_NO_COLOUR'
@@ -102,15 +104,24 @@ function setprompt()
 }
 setprompt
 
+# Obtain the autofs mountpoints
+autofs_mp=""
+[ -r /etc/auto.master ] && autofs_mp=$(grep -e "^/" /etc/auto.master)
 
 function precmd ()
 {
        local exitstatus="${?}"
-       PR_STUFF=" "
+       PR_STUFF=""
        if [[ 0 -ne "${exitstatus}" ]] ; then
-               PR_STUFF="${PR_RED}RET ${exitstatus}${PR_NO_COLOUR}"
+               PR_STUFF=" ${PR_RED}RET ${exitstatus}${PR_NO_COLOUR}"
+       fi
+
+       # autofs always complains not being able to mount .hg/ and the like
+       if echo "$autofs_mp" | grep -qe "^$PWD\s"; then
+               vcs_info_msg_0_="${PR_YELLOW}[autofs]${PR_NO_COLOUR}"
+       else
+               vcs_info
        fi
-       vcs_info
 }