Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Buffer stack in Vi mode
- X-seq: zsh-users 20328
- From: Evgeny Pakhomov <p1himik@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Buffer stack in Vi mode
- Date: Tue, 21 Jul 2015 13:58:36 +0600
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=XZLTo4wPEi/OzVYgeDl7R8TBn75CVENToKJ7Krj8v+k=; b=bTbfRqmZvut/57FLoy11vahVTvuLL0VllVGGUo+mVBaf25V8rXsRB2aQ0W3/ENimjk /J8WhQSYLpZgrpHkqKhUPQ2VnTCBYF81fpzB9QCkHNMKlCE+9CocVaSpVJb9FvW3UMPR AL2myULRYMcxul39kY3OK4xxdR8r9s/vcVh+xK68CuDpcKjNGs4uCMc+hTra3fks+Q29 S6Rt9Ta2NgNm0K1dd4h5Rb4U5uu6daPfqjcY6I1B5P4iX7OnhAecKqYHrGi9Zv/oJRo4 Q9Fy7bJ4KglbtAbG4wuCXl2ZLqDlWyYebiS7W2MS/NdyqOpOammuBskc9/FOPIdvKpjX jhUQ==
- In-reply-to: <150720101425.ZM14010@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAMBZu14=TciXuUGeNu-abNf4+MqLDssroCkcxnOraemy2Jmo4A@mail.gmail.com> <150720101425.ZM14010@torch.brasslantern.com>
Hi Bart,
Thanks for the answer, the widget approach works great!
Just as a remark - hh knows about zsh and different history options. There
are no problems with EXTENDED_HISTORY on my setup.
Regards,
Eugene
On Mon, Jul 20, 2015 at 11:14 PM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
wrote:
> On Jul 20, 8:45pm, Evgeny Pakhomov wrote:
> }
> } Excuse me if it's not the correct place to ask - I couldn't find any
> better.
> }
> } I'm trying to use a custom incremental history search command (
> } https://github.com/dvorka/hstr). It works great with "C-r" in the normal
> } mode, but in the Vi mode I can't use it in the same way - I can't find
> any
> } documentation on how to use buffer stack to save already entered command
> in
> } the Vi mode.
>
> Some remarks:
>
> This is using an external program to read the history file, which means
> it's probably going to break horribly for a lot of zsh configurations.
> The EXTENDED_HISTORY option will probably kill it, which means that the
> INC_APPEND_HISTORY_TIME and SHARE_HISTORY options will also break it.
> Also if you DO NOT set INC_APPEND_HISTORY, you'll only be able to look
> at the history from before the last time a shell exited.
>
> The recommended way to configure this for zsh:
>
> bindkey -s "\C-r" "\eqhh\n"
>
> is using the default binding "\eq" for the push-line widget, which means
> this also probably works not-so-well at the PS2 prompt (in a multi-line
> construct like a "for" loop). But I guess no worse that it would work
> for bash in the same circumstances.
>
> I'm not going to attempt to learn what else that external program does;
> there are a lot of ways to search history in zsh already.
>
> Anyway, the direct answer to your question is that you need to bind the
> push-line widget to keystrokes in the vi mode keymap and then replace
> "\eq" in the bindkey above with those keystrokes. Perhaps:
>
> bindkey -v
> bindkey "^Xq" push-line
> bindkey -s "^R" "^Xqhh\n"
>
> The other answer is that this should be written as a widget and should
> not use the -s option of bindkey at all:
>
> invoke-hh() { hh </dev/tty ; zle -I }
> zle -N invoke-hh
> bindkey -M emacs "^R" invoke-hh
> bindkey -M viins "^R" invoke-hh
>
> Since ^R is already bound to redisplay in vi-mode, you may want to choose
> something else there.
>
> Important note: I didn't actually look at the configuration that hh is
> adding to your startup files. If "hh" is being created as an alias,
> then the widget implementation won't work (at least, not exactly as I
> wrote it) and you'll have to stick with using "bindkey -s".
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author