zsh-users
 help / color / mirror / code / Atom feed
* more tcsh-like history-search capability
@ 2000-10-18  0:31 E. Jay Berkenbilt
  2000-10-18  3:07 ` Danek Duvall
  0 siblings, 1 reply; 3+ messages in thread
From: E. Jay Berkenbilt @ 2000-10-18  0:31 UTC (permalink / raw)
  To: zsh-users


By default, zsh's history-search functions look through history for
lines whose first word starts with the first word on the command line.
I prefer to search for commands that start with the string before the
cursor.

After snarfing Bart's code to handle the literal history stuff
(zsh-workers/10996), it occurred to me that I could solve my history
search problem with zle widgets as well.  This was one of the (many)
areas of zsh that I had not explored at all.  Here are my trivial zle
widgets that implement history searching the way I want it.

I don't have a good name for these widgets... the q- here is the same
as the q in ql.org -- my favorite letter.  (Some people don't outgrow
their favorite letters. :-])

It makes me happy to be using a shell that can be customized like
this. :-)

---------------------------------------------------------------------------

q-history-search-backward()
{
    local cursor=$CURSOR
    zle .history-search-backward "$LBUFFER"
    CURSOR=$cursor
}

q-history-search-forward()
{
    local cursor=$CURSOR
    zle .history-search-forward "$LBUFFER"
    CURSOR=$cursor
}

zle -N q-history-search-backward
zle -N q-history-search-forward

bindkey "^[p" q-history-search-backward
bindkey "^[n" q-history-search-forward

---------------------------------------------------------------------------

--
E. Jay Berkenbilt (ejb@ql.org)  |  http://www.ql.org/q/


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

* Re: more tcsh-like history-search capability
  2000-10-18  0:31 more tcsh-like history-search capability E. Jay Berkenbilt
@ 2000-10-18  3:07 ` Danek Duvall
  2000-10-19  3:57   ` E. Jay Berkenbilt
  0 siblings, 1 reply; 3+ messages in thread
From: Danek Duvall @ 2000-10-18  3:07 UTC (permalink / raw)
  To: E. Jay Berkenbilt; +Cc: zsh-users

On Tue, Oct 17, 2000 at 08:31:23PM -0400, E. Jay Berkenbilt wrote:

> By default, zsh's history-search functions look through history for
> lines whose first word starts with the first word on the command line.
> I prefer to search for commands that start with the string before the
> cursor.

So do I.  And zsh even has these built-in:

    history-beginning-search-backward
    history-beginning-search-forward

:)

Danek


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

* Re: more tcsh-like history-search capability
  2000-10-18  3:07 ` Danek Duvall
@ 2000-10-19  3:57   ` E. Jay Berkenbilt
  0 siblings, 0 replies; 3+ messages in thread
From: E. Jay Berkenbilt @ 2000-10-19  3:57 UTC (permalink / raw)
  To: duvall; +Cc: zsh-users


>   > By default, zsh's history-search functions look through history for
>   > lines whose first word starts with the first word on the command line.
>   > I prefer to search for commands that start with the string before the
>   > cursor.
>
>   So do I.  And zsh even has these built-in:
>
>       history-beginning-search-backward
>       history-beginning-search-forward
>
>   :)

Wow.  It does *exactly* what my code does.  I even looked for
something in the documentation but I guess I missed it.  Oh well --
yet another wheel reinvention.  Thanks for bringing this to my
attention. :-)

At least my reinvented wheel was still round. :-)

                                Jay


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

end of thread, other threads:[~2000-10-19  3:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-18  0:31 more tcsh-like history-search capability E. Jay Berkenbilt
2000-10-18  3:07 ` Danek Duvall
2000-10-19  3:57   ` E. Jay Berkenbilt

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).