Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: # of commands, not PERIODIC
- X-seq: zsh-workers 692
- From: wischnow@xxxxxxxxxxxxxxxxxxxxxxx (Sven Wischnowsky)
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: Re: # of commands, not PERIODIC
- Date: Thu, 14 Dec 1995 08:34:23 +0100 (MET)
- In-reply-to: Uncle Tim's message of Thu, 14 Dec 1995 01:12:47 -0500 (EST)
Uncle Tim wrote:
>
>
>
> I know of the periodic command, which works based on a set-time.
> I'd like some command which will be run based on the number of
> commands which are entered into the history list. I'd like to have
> something run every 10 lines or so...
>
You can do that with precmd:
precmd() {
local h=$[ $(print -P '%h') % 10 ]
if [[ $h -eq 0 ]] then
...
fi
}
Interestingly neither `if [[ $(print -P '%h') % 10 -eq 0 ]]', nor
`h=$(print -P '%h'); if [[ $h % 10 -eq 0]]' works, both give a parse
error.
Oops, I just found, that:
precmd() { [ ( $(print -P '%h') % 10 ) -eq 0 ] && ... }
works (with the `[...]' thing, but not with `[[...]]').
Bye
Sven
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author