zsh-users
 help / color / mirror / code / Atom feed
* Enhanced  history-incremental-search
@ 2022-08-16 10:41 Dominik Vogt
  2022-08-16 20:27 ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Dominik Vogt @ 2022-08-16 10:41 UTC (permalink / raw)
  To: Zsh Users

I'd like to have a context sensitive kind of
history-incremental-search-*.

Assuming the history has the following entries:

  (1) cd /foo/bar/baz
  (2) xpdf foo.pdf

Typing

  $ cd <ctrl-r>foo

should find only (1).

  $ x<ctrl-r>foo

should find (2).

  $ <ctrl-r>foo<crtl-r>

should cycle through both results.

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Enhanced history-incremental-search
  2022-08-16 10:41 Enhanced history-incremental-search Dominik Vogt
@ 2022-08-16 20:27 ` Bart Schaefer
  2022-08-17  9:23   ` Dominik Vogt
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2022-08-16 20:27 UTC (permalink / raw)
  To: dominik.vogt, Zsh Users

On Tue, Aug 16, 2022 at 3:41 AM Dominik Vogt <dominik.vogt@gmx.de> wrote:
>
> I'd like to have a context sensitive kind of
> history-incremental-search-*.

history-beginning-incremental-search-backward () {
  zle -U "^${LBUFFER}${BUFFER:+*}"
  zle history-incremental-pattern-search-backward -K ipsearchback
}
zle -N history-beginning-incremental-search-backward
bindkey ^R history-beginning-incremental-search-backward
bindkey -A isearch ipsearchback
bindkey -M ipsearchback ^R history-incremental-search-backward

The "cycle" part is left as an exercise, because that's not supported
natively by the history-incremental-* widgets.  The user-contributed
history-pattern-search and history-beginning-search-menu widgets may
also be helpful.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Enhanced history-incremental-search
  2022-08-16 20:27 ` Bart Schaefer
@ 2022-08-17  9:23   ` Dominik Vogt
  2022-08-17 22:00     ` Zach Riggle
  0 siblings, 1 reply; 7+ messages in thread
From: Dominik Vogt @ 2022-08-17  9:23 UTC (permalink / raw)
  To: Zsh Users

On Tue, Aug 16, 2022 at 01:27:07PM -0700, Bart Schaefer wrote:
> On Tue, Aug 16, 2022 at 3:41 AM Dominik Vogt <dominik.vogt@gmx.de> wrote:
> >
> > I'd like to have a context sensitive kind of
> > history-incremental-search-*.
>
> history-beginning-incremental-search-backward () {
>   zle -U "^${LBUFFER}${BUFFER:+*}"
>   zle history-incremental-pattern-search-backward -K ipsearchback
> }
> zle -N history-beginning-incremental-search-backward
> bindkey ^R history-beginning-incremental-search-backward
> bindkey -A isearch ipsearchback
> bindkey -M ipsearchback ^R history-incremental-search-backward

Thanks a lot, that works fine!

> The "cycle" part is left as an exercise, because that's not supported
> natively by the history-incremental-* widgets.

That was only bad choice of words.  In a history with two million
lines it is pointless to search in cycles.

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Enhanced history-incremental-search
  2022-08-17  9:23   ` Dominik Vogt
@ 2022-08-17 22:00     ` Zach Riggle
  2022-08-17 22:54       ` Bart Schaefer
  2022-09-02 12:32       ` Vincent Lefevre
  0 siblings, 2 replies; 7+ messages in thread
From: Zach Riggle @ 2022-08-17 22:00 UTC (permalink / raw)
  To: dominik.vogt, Zsh Users

[-- Attachment #1: Type: text/plain, Size: 1353 bytes --]

I'm a big fan of history-substring-search, which lets you type any portion
of a command and just hit ↑ and scroll through the matches.  No need for
Ctrl+R keyboard combo, just arrow keys.

https://github.com/zsh-users/zsh-history-substring-search

*Zach Riggle*


On Wed, Aug 17, 2022 at 2:24 AM Dominik Vogt <dominik.vogt@gmx.de> wrote:

> On Tue, Aug 16, 2022 at 01:27:07PM -0700, Bart Schaefer wrote:
> > On Tue, Aug 16, 2022 at 3:41 AM Dominik Vogt <dominik.vogt@gmx.de>
> wrote:
> > >
> > > I'd like to have a context sensitive kind of
> > > history-incremental-search-*.
> >
> > history-beginning-incremental-search-backward () {
> >   zle -U "^${LBUFFER}${BUFFER:+*}"
> >   zle history-incremental-pattern-search-backward -K ipsearchback
> > }
> > zle -N history-beginning-incremental-search-backward
> > bindkey ^R history-beginning-incremental-search-backward
> > bindkey -A isearch ipsearchback
> > bindkey -M ipsearchback ^R history-incremental-search-backward
>
> Thanks a lot, that works fine!
>
> > The "cycle" part is left as an exercise, because that's not supported
> > natively by the history-incremental-* widgets.
>
> That was only bad choice of words.  In a history with two million
> lines it is pointless to search in cycles.
>
> Ciao
>
> Dominik ^_^  ^_^
>
> --
>
> Dominik Vogt
>
>

[-- Attachment #2: Type: text/html, Size: 2126 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Enhanced history-incremental-search
  2022-08-17 22:00     ` Zach Riggle
@ 2022-08-17 22:54       ` Bart Schaefer
  2022-08-19  1:36         ` Zach Riggle
  2022-09-02 12:32       ` Vincent Lefevre
  1 sibling, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2022-08-17 22:54 UTC (permalink / raw)
  To: Zach Riggle; +Cc: dominik.vogt, Zsh Users

On Wed, Aug 17, 2022 at 3:00 PM Zach Riggle <zachriggle@gmail.com> wrote:
>
> I'm a big fan of history-substring-search, which lets you type any portion of a command and just hit ↑ and scroll through the matches.  No need for Ctrl+R keyboard combo, just arrow keys.
>
> https://github.com/zsh-users/zsh-history-substring-search

Wow, what a lot of code.  I think enabling isearch highlighting and
using my widget (duplicated to be able to search forward as well)
would cover 80% of this.  A couple of checks for whether to stick a ^
or a * at the front of the search pattern would cover another 10%.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Enhanced history-incremental-search
  2022-08-17 22:54       ` Bart Schaefer
@ 2022-08-19  1:36         ` Zach Riggle
  0 siblings, 0 replies; 7+ messages in thread
From: Zach Riggle @ 2022-08-19  1:36 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: dominik.vogt, Zsh Users

[-- Attachment #1: Type: text/plain, Size: 796 bytes --]

It's a lot of comments, the amount of code isn't actually too much!

On Wed, Aug 17, 2022 at 3:54 PM Bart Schaefer <schaefer@brasslantern.com>
wrote:

> On Wed, Aug 17, 2022 at 3:00 PM Zach Riggle <zachriggle@gmail.com> wrote:
> >
> > I'm a big fan of history-substring-search, which lets you type any
> portion of a command and just hit ↑ and scroll through the matches.  No
> need for Ctrl+R keyboard combo, just arrow keys.
> >
> > https://github.com/zsh-users/zsh-history-substring-search
>
> Wow, what a lot of code.  I think enabling isearch highlighting and
> using my widget (duplicated to be able to search forward as well)
> would cover 80% of this.  A couple of checks for whether to stick a ^
> or a * at the front of the search pattern would cover another 10%.
>

[-- Attachment #2: Type: text/html, Size: 1284 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Enhanced history-incremental-search
  2022-08-17 22:00     ` Zach Riggle
  2022-08-17 22:54       ` Bart Schaefer
@ 2022-09-02 12:32       ` Vincent Lefevre
  1 sibling, 0 replies; 7+ messages in thread
From: Vincent Lefevre @ 2022-09-02 12:32 UTC (permalink / raw)
  To: zsh-users

On 2022-08-17 15:00:19 -0700, Zach Riggle wrote:
> I'm a big fan of history-substring-search, which lets you type any portion
> of a command and just hit ↑ and scroll through the matches.  No need for
> Ctrl+R keyboard combo, just arrow keys.
> 
> https://github.com/zsh-users/zsh-history-substring-search

Good idea, though I wouldn't like it as it is, since I often search
some command, then go back in the history to get the beginning of
the sequence of commands I want. However, I would like something
like that, but instead of the up arrow, PageUp to behave as Ctrl-R
(and PageDown as Ctrl-S).

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-09-02 12:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-16 10:41 Enhanced history-incremental-search Dominik Vogt
2022-08-16 20:27 ` Bart Schaefer
2022-08-17  9:23   ` Dominik Vogt
2022-08-17 22:00     ` Zach Riggle
2022-08-17 22:54       ` Bart Schaefer
2022-08-19  1:36         ` Zach Riggle
2022-09-02 12:32       ` Vincent Lefevre

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