This commit is contained in:
Tiziano Santoro 2017-05-06 15:56:51 +00:00 committed by GitHub
commit d544fd8be3

View file

@ -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
}