Add failed systemctl services to root's prompt
authorChristoph Egger <christoph@christoph-egger.org>
Sat, 1 Aug 2015 16:48:46 +0000 (18:48 +0200)
committerChristoph Egger <christoph@christoph-egger.org>
Sat, 1 Aug 2015 16:48:46 +0000 (18:48 +0200)
zshrc

diff --git a/zshrc b/zshrc
index a6df1013f42361caa972ccd9a6f449a9d81168aa..abd47ce5a61cbf00d758a90a76009d23573bc82b 100644 (file)
--- a/zshrc
+++ b/zshrc
@@ -55,6 +55,12 @@ setWindowTitle(){
 precmd () {
     vcs_info
     setWindowTitle ${USER}@${HOST}
+
+    if [[ $UID == 0  && -f `which systemctl` ]]
+    then
+      use_systemd=true
+      systemd_failed="`systemctl --state=failed | grep failed | cut -d \  -f 2 | tr '\n' ' '`"
+    fi
 }
 
 config=("default" "`uname -s`")
@@ -78,7 +84,15 @@ case "${DOMAIN//cs.fau.de/informatik.uni-erlangen.de}" in
                ;;
 esac
 
-PROMPT=$'%{$fg[yellow]%}%n@%{$fg[magenta]%}%m%{$reset_color%} %~ \n%{$fg[cyan]%}%T%{$reset_color%} %0(?,%{$fg[green]%},%{$fg[red]%}%s)%?%{$reset_color%} %# '
+if [[ $UID == 0  && -f `which systemctl` ]]
+then
+  PROMPT=$'%{$fg[red]>>  $systemd_failed$reset_color%}\n'
+else
+  PROMPT=""
+fi
+
+PROMPT+=$'%{$fg[yellow]%}%n@%{$fg[magenta]%}%m%{$reset_color%} %~ \n%{$fg[cyan]%}%T%{$reset_color%} %0(?,%{$fg[green]%},%{$fg[red]%}%s)%?%{$reset_color%} %# '
+
 RPROMPT='${vcs_info_msg_0_}'
 
 export DEBEMAIL='christoph@debian.org'