From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23222 invoked by alias); 13 Oct 2011 19:32:58 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16480 Received: (qmail 19268 invoked from network); 13 Oct 2011 19:32:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <111013123237.ZM9529@torch.brasslantern.com> Date: Thu, 13 Oct 2011 12:32:37 -0700 In-reply-to: <5F28EC71-35D4-45EF-9F75-FE853DF420BA@gmail.com> Comments: In reply to Aaron Davies "Re: Would like an alias to read the part of the current command line that precedes the alias" (Oct 12, 11:15pm) References: <20111010231518.BFD1A10E2AA@smtp.hushmail.com> <111010190517.ZM5763@torch.brasslantern.com> <5F28EC71-35D4-45EF-9F75-FE853DF420BA@gmail.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Would like an alias to read the part of the current command line that precedes the alias MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Oct 12, 11:15pm, Aaron Davies wrote: } } First, and I think this is general, it triggers again off of a blank } command line (i.e. pressing return a second time) after the specified } time has elapsed. You can fix this by keeping track of $HISTCMD and skipping the alert if it hasn't incremented. } Second, and this is probably due to my setup, I can't get the failure } detection working. The third growlnotify call below should have a -a } argument of "Problem Reporter". } } Any idea what I'm doing wrong? My example was incomplete. I tested without the (( SECONDS > N )) and that resets $? before the part after the && happens. typeset -g _LASTALERT=$HISTCMD preexec() { SECONDS=0 } precmd() { local alert="${${?/0/Terminal}//<->*/Problem Reporter}" (( _LASTALERT < HISTCMD && SECONDS > 1 )) && growlnotify -p "Very Low" -a "$alert" -m "$history[$_LASTALERT]" _LASTALERT=$HISTCMD } Note that this is also going to put up a dialog if you interrupt a command with ctrl-c. Fixing that would involve saving $? and checking for what signal it indicates was received, i.e. ^C is 130.