zsh-users
 help / color / mirror / code / Atom feed
From: "E. Jay Berkenbilt" <ejb@ql.org>
To: zsh-users@sunsite.auc.dk
Subject: more tcsh-like history-search capability
Date: Tue, 17 Oct 2000 20:31:23 -0400	[thread overview]
Message-ID: <200010180031.UAA21435@soup.ql.org> (raw)


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/


             reply	other threads:[~2000-10-18  0:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-18  0:31 E. Jay Berkenbilt [this message]
2000-10-18  3:07 ` Danek Duvall
2000-10-19  3:57   ` E. Jay Berkenbilt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200010180031.UAA21435@soup.ql.org \
    --to=ejb@ql.org \
    --cc=zsh-users@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).