From: dnelson@emsphone.com (Dan Nelson)
To: schaefer@nbn.com
Cc: nmj3e@virginia.edu (Nate Johnston), zsh-users@math.gatech.edu
Subject: Re: Mailpath notification message
Date: Tue, 5 Nov 1996 23:56:02 -0600 [thread overview]
Message-ID: <199611060556.XAA06788@dan.emsphone.com> (raw)
In-Reply-To: <961105131929.ZM5724@candle.brasslantern.com>; from "Bart Schaefer" on Nov 5, 1996 13:19:29 -0800
In the last eposode (Nov 5), Bart Schaefer said:
> On Nov 5, 3:13pm, Nate Johnston wrote:
> } setopt magic_equal_subst # for `export foo=~/bar`
> } function export() { EXPORT=${1%%\=*} ; typeset -Ux $* }
> } function +() { eval builtin export ${EXPORT}=\$\{$EXPORT\}:\$1 }
> } # some stuff snipped
> } export MAILPATH= "~/mail/in/inbox?Mail in folder 1"
> } + "~/.samizdat/in/inbox?Mail in filder 2"
> } # more snipped
> } unfunction export +
That looks.. weird :) I would rather keep sh-style syntax myself, plus
a notation easy for novices to use.
Here is a set of functions based around elm's "frm" command. In
addition to "You have new Z-Shell" mail messages generated by the
mailpath variable, the frm command prints an extra line for every
mailbox with messages in it:
You have no mail.
You have 5 messages from the Z-Shell listserv.
I know only enough about zsh's variable substitution to be dangerous,
so my functions might be affected by setopt's I don't know about.
-Dan Nelson
dnelson@emsphone.com
To use, put these two functions in .zshenv ( or /etc/zshenv):
---.zshenv---
# _subfrm: Counts messages in a mailbox. Argument 1 is the path of the
# mailbox. Argument 2 is assumed to be a string of the form "You have
# new #### mail.". The 2nd word from the right is pulled out and
# included in the message count. No message is printed if the mailbox
# size is 0. Messages are counted by grepping for "From " at the
# beginning of a line. MMDF users might want to search for ^A's.
_subfrm()
{
if [[ -s $@[1] ]] ; then
local msg
msg=(${=@[2]})
echo "You have" $(grep -c "^From " $@[1]) "messages from the $msg[4,-2] listserv."
else
fi
}
# frm: Parses the ZSH mailpath to print number of messages in each
# mailbox. Skips the first entry, which is assumed to be the user's
# main mailbox (handled by the real frm command). Each array element
# after that is passed to _subfrm.
frm()
{
local i
command frm
for i in $mailpath[2,-1]
_subfrm ${(s/?/)i}
true
# This is here so that frm() always returns success
# The picky will want to save the result of "command frm" and
# return that.
}
---.zshenv---
And add these to .zprofile or .zlogin:
---.zprofile---
# Addfrm: Appends a mailbox to the zsh mailpath array. Argument 1 is
# the path to the mailbox. Argument 2 is a single word describing the
# list. Don't quote this to put spaces in it, as _subfrm splits on
# spaces to extract the description from $mailpath.
addfrm()
{
if [[ -z $@[2] ]] ; then
mailpath=($mailpath $@[1])
else
mailpath=($mailpath $@[1]"?You have new "$@[2]" mail.")
fi
}
export MAILPATH=/var/mail/$USER
addfrm ~/Mail/zsh Z-Shell
# Add other mailboxes here
unfunction addfrm
#don't need it any more
---.zprofile---
next prev parent reply other threads:[~1996-11-06 6:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-10-24 4:37 Rusty Hoover
1996-10-24 5:20 ` Jason L Tibbitts III
1996-11-05 20:13 ` Nate Johnston
1996-11-05 21:19 ` Bart Schaefer
1996-11-06 5:56 ` Dan Nelson [this message]
1996-10-24 7:35 ` Peter Stephenson
1996-10-24 8:41 ` Duncan Sargeant
1996-10-24 9:11 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199611060556.XAA06788@dan.emsphone.com \
--to=dnelson@emsphone.com \
--cc=nmj3e@virginia.edu \
--cc=schaefer@nbn.com \
--cc=zsh-users@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).