Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: # of commands, not PERIODIC



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