From: Frank Terbeck Date: Tue, 5 Mar 2013 13:35:46 +0000 (+0100) Subject: zshrc: New prompt: Provide fallback in case promptinit fails X-Git-Tag: v0.8.0~37 X-Git-Url: http://git.grml.org/?p=grml-etc-core.git;a=commitdiff_plain;h=db038bb74540fecc9aaef863aac762dba7df3ea7 zshrc: New prompt: Provide fallback in case promptinit fails This should not happen usually. But better be safe than sorry. In case something goes wrong we only support _one_ prompt, with the original root-is-red changeroo. This is good enough as a fallback. Signed-off-by: Frank Terbeck --- diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index b4ec1b7..7e2e53a 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -1562,9 +1562,21 @@ if zrcautoload promptinit && promptinit 2>/dev/null ; then fi else print 'Notice: no promptinit available :(' -fi -setopt prompt_subst + # Support a fallback, in case promptsys isn't available. + setopt prompt_subst + + precmd() { (( ${+functions[vcs_info]} )) && vcs_info; } + + p0="${RED}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}" + p1="${BLUE}%n${NO_COLOR}@%m %40<...<%B%~%b%<< "'${vcs_info_msg_0_}'"%# " + if (( EUID == 0 )); then + PROMPT="${BLUE}${p0}${RED}${p1}" + else + PROMPT="${RED}${p0}${BLUE}${p1}" + fi + unset p0 p1 +fi # make sure to use right prompt only when not running a command is41 && setopt transient_rprompt