zsh-workers
 help / color / mirror / code / Atom feed
* Current history number in command line
@ 2008-10-12 21:25 Jörg Sommer
  2008-10-13  3:30 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Jörg Sommer @ 2008-10-12 21:25 UTC (permalink / raw)
  To: zsh-workers

Hi,

while searching the history with ^R, is it possible to get the number of
the current history entry? I'm using %h in my prompt, but this is only
the number of the next history entry. While going up and down the history
list I would like to see the number of the selected history entry. Is
this possible?

Bye, Jörg.
-- 
Diskutiere nie mit einem Idioten:
Sie ziehen Dich auf ihr Niveau herab und schlagen Dich dann mit
Erfahrung.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Current history number in command line
  2008-10-12 21:25 Current history number in command line Jörg Sommer
@ 2008-10-13  3:30 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2008-10-13  3:30 UTC (permalink / raw)
  To: zsh-workers

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-13  3:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-12 21:25 Current history number in command line Jörg Sommer
2008-10-13  3:30 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).