From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26359 invoked by alias); 14 Dec 2009 00:26:07 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27509 Received: (qmail 27778 invoked from network); 14 Dec 2009 00:26:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <091213152534.ZM13525@torch.brasslantern.com> Date: Sun, 13 Dec 2009 15:25:34 -0800 In-reply-to: <140222.25175.qm@web65614.mail.ac4.yahoo.com> Comments: In reply to Guido van Steen "matlab-history-beginning-search-backward" (Sep 30, 9:52am) References: <140222.25175.qm@web65614.mail.ac4.yahoo.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Guido van Steen , zsh-workers@zsh.org Subject: Re: matlab-history-beginning-search-backward MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Nobody ever responded to this thread ... On Sep 30, 9:52am, Guido van Steen wrote: } Subject: matlab-history-beginning-search-backward } } I would prefer a similar [to history-beginning-search-backward] } widget that searches for commands in the command history, in such a } way that "LBUFFER" is a SUBSTRING of these commands. (This is the } default history management in MATLAB and FISH.) } } I know there is the "history-incremental-search-backward" widget, } which is bound to "^r" by default. This widget does more-or-less what } I want. However, it shows two prompts, which I don't seem to like that } much. Moreover, if requires the userto invoke it first and then start } typing what he looks for. Ignoring the issue of the extra prompt, what you want can be accomplished like so: matlab-history-beginning-search-backward() { local search="$LBUFFER" zle up-line-or-history zle end-of-line zle history-incremental-search-backward "$search" } zle -N matlab-history-beginning-search-backward bindkey ^X^P matlab-history-beginning-search-backward bindkey -M isearch ^X^P history-incremental-search-backward The tricky bit there is that you use one keybinding to enter incremental search mode, and then bind the same keys in the special isearch map to repeat that search. The other point to note is that you can start an incremental search with an initial string by passing it as an argument.