diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 07546fd34..75ba7cb0d 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -185,6 +185,22 @@ prompt_hg() { fi } +prompt_maildir() { + # Avoid zsh complaining for ** not matching anything. + unsetopt nomatch 2>/dev/null + # Only enable this segment if the $MAILDIR variable is set. + if [[ -n "$MAILDIR" ]] then + # $MAILDIR should be set to something like "~/Maildir/INBOX/new" for a single maildir, or + # "~/Maildir/**/INBOX/new" in case of multiple maildirs in the same folder (if using offlineimap + # or similar). + eval ls "$MAILDIR/*" >/dev/null 2>&1 + # ls succeeds if there is at least one file matching the pattern. + if [[ $? -eq 0 ]] then + prompt_segment black red "M" + fi + fi +} + # Dir: current working directory prompt_dir() { prompt_segment blue black '%~' @@ -222,6 +238,7 @@ build_prompt() { prompt_git prompt_bzr prompt_hg + prompt_maildir prompt_end }