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

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