Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: 2nd mail question :)
- X-seq: zsh-users 3963
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: Jörg Ziefle <gt4556a@xxxxxxxxxxxxxxxx>, zsh-users@xxxxxxxxxx
- Subject: Re: 2nd mail question :)
- Date: Wed, 27 Jun 2001 07:28:21 +0000
- In-reply-to: <20010626233435.A4263@xxxxxxxxxxxxxxxx>Comments: In reply to Jörg Ziefle <gt4556a@xxxxxxxxxxxxxxxx> "2nd mail question :)" (Jun 26, 11:34pm)
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20010626233435.A4263@xxxxxxxxxxxxxxxx>
On Jun 26, 11:34pm, Jörg Ziefle wrote:
} Subject: 2nd mail question :)
}
} Does anybody see a way to execute an external program when new mail has
} come in? Events, for example?
It's not really documented, but you can put any $-expansion you like in
the notification message in mailpath. E.g.:
mailpath=( $HOME/Mail'?New mail in $_ at $(date)' )
} What I wanna do is when new mail arrives, I want to have a little
} program executed that starts my mailer with the right folder
} (user-specified if several folders have received mail).
Hrm. Why not just leave your mailer running and let it do the new mail
checking? (Secondary question, why not get a better mailer?)
The thing to remember about stuff in $(...) is that zsh wants to read
the output from it -- so zsh will wait not just until the program exits,
but until it actually reads end-of-file, which means even putting the
program in the background won't necessarily unblock zsh. At the same
time, the program's output (and maybe input) are directed away from the
terminal, so unless you explicitly point them back you can't interact
with the program.
So if you really want zsh to automatically fire up some kind of mail
client when new mail arrives, you need something like:
mailpath=( $HOME/Mail'?$(mutt -f "$_" </dev/tty >&/dev/tty)' )
Note placement of single vs. double quotes. Note also that zsh will run
this once for every file that has new mail. A better solution might be
something like this:
mailpath=( $HOME/Mail'?$(echo "$_" >>| ~/.newmail) )
precmd() {
if [[ -f ~/.newmail ]]; then
# There'll be one line for each mailbox.
# Run your mailer appropriately.
mutt -f "$(head -1 ~/.newmail)" # or whatever
rm ~/.newmail
fi
}
I predict, however, that after at most a day of having your mail client
repeatedly pop open in the middle of whatever else you're doing, you will
abandon this idea.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
Messages sorted by:
Reverse Date,
Date,
Thread,
Author