Re: Open folder only when there in new mail
On 2004-02-22, romildo@xxxxxxxxxxx wrote:
> On Sun, Feb 22, 2004 at 08:13:10AM -0500, David Yitzchak Cohen wrote:
> > On Sun, Feb 22, 2004 at 03:14:19AM EST, Gary Johnson wrote:
> > > On 2004-02-21, romildo@xxxxxxxxxxx wrote:
> >
> > > > Is it possible to have
> > > >
> > > > $ mutt -f <folder>
> > > >
> > > > to open <folder> only if there is new mail
> > > > in it? If there is no mail in <folder>,
> > > > mutt should just quit. How to get this
> > > > behaviour?
> > >
> > > >From the mutt(1) man page:
> > >
> > > OPTIONS
> > > ...
> > >
> > > -z When used with -f, causes Mutt not to start if there are no
> > > messages in the mailbox.
> >
> > He's looking to quit if there's no _new_ mail in the folder, unless I
> > misread his OP.
>
> David is right. If there isn't new messages in the folder, mutt
> should quit immediatelly, even if the folder is not empty.
I see that now. Sorry about that.
> Any help?
You could write a script that checks for new mail, then runs mutt
only if there is new mail. For example, the following checks the
mailbox supplied as the argument for any mail that does not include
the Status header. This header is added by mutt when it has read a
message. If there is at least one such message in the mailbox, the
script executes mutt on that mailbox.
if [ $(grepmail -v -h '^Status: ' $1 | wc -l) -gt 0 ]
then
mutt -f $1
fi
Only partly tested.
HTH,
Gary
--
Gary Johnson | Agilent Technologies
garyjohn@xxxxxxxxxxxxxxx | Wireless Division
http://www.spocom.com/users/gjohnson/mutt/ | Spokane, Washington, USA