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

Re: !!:$



On Tue, 16 Nov 2004, Peter Stephenson wrote:

> [...]  $history is an associative array and you need
> to know the event number, which currently isn't available as a
> parameter: you can get it from a prompt, but not directly.  This strikes
> me as a curious omission.  How about adding it using the same name as
> bash?

Umm.

HISTNO (integer)
     The current history number.  Setting this has the same effect as
     moving up or down in the history to the corresponding history line.
     An attempt to set it is ignored if the line is not stored in the
     history.

Admittedly this is available only in widgets, but it seems odd to have two
variables for the same thing.

> Then you can always get the full previous line as
> $history[$((HISTCMD-1))].

Unfortunately that doesn't always work.  If you setopt HIST_IGNORE_DUPS,
$history[$((HISTNO-1))] may be empty.

The only thing that always works is $history[${${(Onk)history}[1]}] or
some similar convolution that gets keys that are known to be in the hash.



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