From: Aaron Davies <aaron.davies@gmail.com>
To: zsh-users@zsh.org
Subject: Re: Would like an alias to read the part of the current command line that precedes the alias
Date: Wed, 12 Oct 2011 23:15:49 -0400 [thread overview]
Message-ID: <5F28EC71-35D4-45EF-9F75-FE853DF420BA@gmail.com> (raw)
In-Reply-To: <111010190517.ZM5763@torch.brasslantern.com>
On Oct 10, 2011, at 10:05 PM, Bart Schaefer wrote:
> However, I suspect most zsh users would do this with a precmd function,
> and never type out the "; alert" at all. For example:
Here's my attempt to build a version for Mac.
I'm having two problems:
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. This is the second growlnotify call below.
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?
pro% echo $ZSH_VERSION
4.3.9
pro% setopt
extendedglob
interactive
login
monitor
shinstdin
zle
pro% typeset -f preexec precmd
preexec () {
SECONDS=0
}
precmd () {
(( SECONDS > 1 )) && growlnotify -p "Very Low" -a "${${?/0/Terminal}//<->*/Problem Reporter}" -m $history[$[HISTCMD-1]]
}
pro% cat succeed
#!/bin/zsh
sleep 2
pro% cat fail
#!/bin/zsh
sleep 2
exit 1
pro% set -x
+precmd:1> (( SECONDS > 1 ))
pro% ./succeed
+preexec:1> SECONDS=0
+-zsh:7> ./succeed
+precmd:1> (( SECONDS > 1 ))
+precmd:3> growlnotify -p 'Very Low' -a Terminal -m ./succeed
pro%
+precmd:1> (( SECONDS > 1 ))
+precmd:3> growlnotify -p 'Very Low' -a Terminal -m ./succeed
pro% ./fail
+preexec:1> SECONDS=0
+-zsh:9> ./fail
+precmd:1> (( SECONDS > 1 ))
+precmd:3> growlnotify -p 'Very Low' -a Terminal -m ./fail
pro%
--
Aaron Davies
aaron.davies@gmail.com
next prev parent reply other threads:[~2011-10-13 3:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-10 23:15 dg1727
2011-10-11 2:05 ` Bart Schaefer
2011-10-13 3:15 ` Aaron Davies [this message]
2011-10-13 19:32 ` Bart Schaefer
2011-11-07 5:12 ` Aaron Davies
2011-10-10 23:21 dg1727
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=5F28EC71-35D4-45EF-9F75-FE853DF420BA@gmail.com \
--to=aaron.davies@gmail.com \
--cc=zsh-users@zsh.org \
/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).