From: Bart Schaefer <schaefer@brasslantern.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: Thu, 13 Oct 2011 12:32:37 -0700 [thread overview]
Message-ID: <111013123237.ZM9529@torch.brasslantern.com> (raw)
In-Reply-To: <5F28EC71-35D4-45EF-9F75-FE853DF420BA@gmail.com>
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.
next prev parent reply other threads:[~2011-10-13 19:32 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
2011-10-13 19:32 ` Bart Schaefer [this message]
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=111013123237.ZM9529@torch.brasslantern.com \
--to=schaefer@brasslantern.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).