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

Re: Current history number in command line



On Oct 12,  9:25pm, Joerg wrote:
}
} while searching the history with ^R, is it possible to get the number of
} the current history entry?

Not easily.

With an ordinary motion widget, you can write a wrapper that grabs the
value of HISTNO and puts it somewhere useful.  Simple example:

    up-line-or-history() {
      zle .up-line-or-history "$@"
      RPS1=$HISTNO
      zle reset-prompt
      zle -R
    }
    zle -N up-line-or-history

With history-incremental-search-*, you don't have this luxury, because
the input and display for the incremental pattern is handled entirely
inside the widget; there is no hook for resetting the prompt.

If you're feeling ambitious, Functions/Zle/history-pattern-search is a
good starting point; it's already manipulating HISTNO so it shouldn't
be hard to find a place to add a few lines to poke something into the
prompt.



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