Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Would like an alias to read the part of the current command line that precedes the alias
- X-seq: zsh-users 16475
- From: Aaron Davies <aaron.davies@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- 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
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; bh=p1txMHcRDOyY2Rawz+5xG489pxZE8RwyUa2N1PHBTtk=; b=D7OfY6xvyRvCQfJcJlSvI7ErH9BB0nKK7dxTqA0MVlQ6ExIcQgu1zqS2xvT079/BfY gFrbZeXqkdmyrm1MCM173DYqQFLnWDHWpYS/qsxqj3d4MAlqj6D8juzDDE6c1fWBm6AX 6YaOEBqGMhA0XL657RvqhwUWjl7Kz/mPASspM=
- In-reply-to: <111010190517.ZM5763@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20111010231518.BFD1A10E2AA@smtp.hushmail.com> <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@xxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author