Well, the title of my question is a little vague. Now let me explain that clearly.
We know there is a "MAILCHECK" in bash, every few minutes bash will check the mailbox and give you a message if you have new mails. Note that you don't need a command for this notification. Bash print a message automatically anytime if there are new mails.
Here, I have few questions:
a certain command
the certain command
1. Mail notification in zsh:
I think it's just like bash; mail notification will take place if the shell knows where to look for mail and if the
MAILCHECK parameter is set to a non-negative integer.
2. Changing the mail notification message.
MAILPATH A colon-separated list of file names to be checked for mail. The message to be printed when mail arrives in a particular file may be specified by separating the file name from the message with a '?'. When used in the text of the message, $_ expands to the name of the current mailfile. Example: MAILPATH='/var/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"' Bash supplies a default value for this variable, but the location of the user mail files that it uses is system dependent (e.g., /var/mail/$USER).
zsh is roughly the same, aside from also exposing
mailpath as the array version of
3. Running arbitrary commands:
bash, the value of
PS1 is printed as a command prompt. Unless the
promptvars options is unset (it is set by default), the string undergoes parameter expansion, command substitution, arithmetic expansion and quote removal before being used. The second of those means that you can execute arbitrary shell commands as part of the command prompt.
zsh has the same feature, controlled by the shell option
PROMPT_SUBST, as the manpage says). Unlike
bash, the shell options is unset by default. Also, you might find that you are unable to change the value of
PS1 (if your distro uses prompt themes), because the prompt theme resets
PS1 before every command prompt.
It turns out that
zsh has a different mechanism for running shell functions before the prompt is printed (or in other circumstances; I'm just going to focus on this one case). There is an array parameter called
precmd_functions whose values are the names of functions which will be run before every prompt. (The prompt theme systems uses this mechanism to reset
PS1 before it is printed.)