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

Re: Repeatable (@M) bug

On Aug 14, 10:53am, Sebastian Gniazdowski wrote:
} Also, when I wrote a script to repeat v-history calls automatically (no
} through command line) it resulted in:
} v-history:fc:21: no such event: 1000
} This is a very interesting result, as the `history -rn 1000` call just must
} work.

Scripts don't normally have history.  How did you run the script?

Glancing through your source code, I suspect the error is not with (@M).

"history 1000" means to start at the 1000th history entry and list up to
the current history entry (which must be event number 1000 or greater,
otherwise you get that "no such event" error).  Adding -r reverses the
order of the output, not the direction of selecting the event numbers.

I suspect you mean "history -rn -1000" to select events up to 1000
history entries ago and list them starting with the current entry.

However, You might avoid running `history -rn` and instead examine
the array $historywords from the zsh/parameter module.  It has all
the individual words from the history with the most recent at the
beginning of the array, which seems to be exactly what you want.

That is, instead of

    list=( `history -rn 1000` )
    list=( "${(@M)list:#*$1*}" )


    zmodload zsh/parameter
    list=( "${(@M)historywords:#*$1*}" )

Messages sorted by: Reverse Date, Date, Thread, Author