好吧,我的问题的标题有点模糊.现在让我清楚地解释一下.
我们知道bash中有一个“MAILCHECK”,每隔几分钟bash会检查邮箱,如果你有新邮件就会给你一条消息.请注意,您不需要此通知的命令.如果有新邮件,Bash会随时自动打印邮件.
在这里,我有几个问题:
>我的zsh中没有这样的通知(也许我忘了我的.zshrc中的内容)
>如何在bash / zsh中更改“新邮件通知”的格式
>在bash / zsh中完成任何命令后如何执行某个命令.例如当我输入ls和< enter>时,将执行ls,然后执行某个命令.
如果我能这样做,自动通知就完成了!
明白了吗?有什么建议吗?
解决方法:
1. zsh中的邮件通知:
我觉得这就像bash;如果shell知道在哪里查找邮件以及MAILCHECK参数是否设置为非负整数,则会发生邮件通知.
2.更改邮件通知消息.
(来自man bash):
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大致相同,除了将mailpath暴露为MAILPATH的数组版本之外.
3.运行任意命令:
在bash中,PS1的值打印为命令提示符.除非取消设置promptvars选项(默认情况下设置),否则字符串在使用前会经历参数扩展,命令替换,算术扩展和引用删除.第二个意味着您可以在命令提示符下执行任意shell命令.
zsh具有相同的功能,由shell选项promptsubst(或PROMPT_SUBST,如联机帮助页所示)控制.与bash不同,默认情况下不设置shell选项.此外,您可能会发现无法更改PS1的值(如果您的发行版使用提示主题),因为提示主题会在每个命令提示符之前重置PS1.
事实证明,在打印提示之前,zsh有一个不同的机制来运行shell函数(或者在其他情况下;我只是关注这一个案例).有一个名为precmd_functions的数组参数,其值是将在每个提示之前运行的函数的名称. (提示主题系统使用此机制在打印之前重置PS1.)
标签:bash,linux,shell,email,notifications
来源: https://codeday.me/bug/20190825/1721186.html