Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Better way to execute commands from history?



2009/9/3 sam reckoner <sam.reckoner@xxxxxxxxx>:
> On Wed, Sep 2, 2009 at 1:24 PM, Mikael Magnusson<mikachu@xxxxxxxxx> wrote:
>> 2009/9/2 sam reckoner <sam.reckoner@xxxxxxxxx>:
>>> Hi,
>>>
>>> I am in the habit of doing the following:
>>>
>>> % fc -l -1000| grep -i cd | grep -i link | tail -1 | cut -d" " -f3
>>>
>>> which gives me the number of the command that contains both "cd" and
>>> "link" in it. I then manually type in
>>>
>>> % !num
>>>
>>> where num is the output of the first command. I know there is a C-R
>>> command, but doing it as above makes it possible to search the entire
>>> string in the history list for multiple items.
>>>
>>> I'm sure there's a better way to do this.
>>
>> If you rebind ^R (and ^[^R) to history-incremental-pattern-search-forward
>> (the default is without the "pattern-"), you can press ^R and type cd*link
>> to get the same result, but you can iterate backwards as usual too.
>>
>> bindkey "^R"   history-incremental-pattern-search-backward
>> bindkey "^[^R" history-incremental-pattern-search-forward
> By the way, I get the following error when I try the bindkey:
>
> No such widget `history-incremental-pattern-search-backward'
>
> I'm not sure I'm using the right version.
>
> % zsh --version
> zsh 4.3.4 (i686-pc-cygwin)

It appears these widgets were added in 4.3.9, I should have checked
that first I guess.

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author