From db038bb74540fecc9aaef863aac762dba7df3ea7 Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Tue, 5 Mar 2013 14:35:46 +0100 Subject: [PATCH] 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 --- etc/zsh/zshrc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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 -- 2.1.4