From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-request@euclid.skiles.gatech.edu Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id RAA06886 for ; Wed, 6 Nov 1996 17:10:00 +1100 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id BAA08924; Wed, 6 Nov 1996 01:08:24 -0500 (EST) Resent-Date: Wed, 6 Nov 1996 00:55:49 -0500 (EST) Message-Id: <199611060556.XAA06788@dan.emsphone.com> Date: Tue, 5 Nov 1996 23:56:02 -0600 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 References: <961105131929.ZM5724@candle.brasslantern.com> X-Mailer: Mutt 0.49 Mime-Version: 1.0 In-Reply-To: <961105131929.ZM5724@candle.brasslantern.com>; from "Bart Schaefer" on Nov 5, 1996 13:19:29 -0800 Resent-Message-ID: <"cJZSF2.0.572.bX2Wo"@euclid> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/496 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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---