zsh-users
 help / color / mirror / code / Atom feed
* incremental history search
@ 2004-02-20 23:04 Thorsten Kampe
  2004-02-20 23:20 ` Björn Lindström
  2004-02-21  1:17 ` Eric Mangold
  0 siblings, 2 replies; 14+ messages in thread
From: Thorsten Kampe @ 2004-02-20 23:04 UTC (permalink / raw)
  To: zsh-users

I have bound[1] the cursor keys to "up-line-or-search" and
down-line-or-search. Unfortunately this only completes the first word
of the search; meaning when I type

wget http://foo.com
wget ftp://bar.com

and then...
wget http[up cursor]
...it completes to "wget ftp://bar.com" and not to the desired "wget
http://foo.com". It only searches matches for the first word ("wget")
of the already typed command line in history.

Is it possible to make zsh search for matches of the whole command
line ("wget http") - and not only the first word?


Thorsten

[1] bindkey "\e[A"  up-line-or-search
    bindkey "\e[B"  down-line-or-search


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

* Re: incremental history search
  2004-02-20 23:04 incremental history search Thorsten Kampe
@ 2004-02-20 23:20 ` Björn Lindström
  2004-02-21  0:54   ` Thorsten Kampe
  2004-02-21  1:17 ` Eric Mangold
  1 sibling, 1 reply; 14+ messages in thread
From: Björn Lindström @ 2004-02-20 23:20 UTC (permalink / raw)
  To: zsh-users

Thorsten Kampe <thorsten@thorstenkampe.de> writes:

> Is it possible to make zsh search for matches of the whole command
> line ("wget http") - and not only the first word?

Have you tried C-r and C-s?

-- 
Björn Lindström <bkhl@elektrubadur.se>
http://bkhl.elektrubadur.se/


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

* Re: incremental history search
  2004-02-20 23:20 ` Björn Lindström
@ 2004-02-21  0:54   ` Thorsten Kampe
  2004-02-21  1:19     ` Philippe Troin
  0 siblings, 1 reply; 14+ messages in thread
From: Thorsten Kampe @ 2004-02-21  0:54 UTC (permalink / raw)
  To: zsh-users

* Björn Lindström (2004-02-21 00:20 +0100)
> Thorsten Kampe <thorsten@thorstenkampe.de> writes:
>> Is it possible to make zsh search for matches of the whole command
>> line ("wget http") - and not only the first word?
> 
> Have you tried C-r and C-s?

C-s just freezes the display and can be unlocked by C-q.

C-r is partly the function I want (although "wget http" also matches
for example "cd tmp; wget http://foo.com"). But C-r is not very
convenient as it disrupts the normal way of typing: it doesn't use
what I already typed:
% wget C-r
bck-i-search: _

Normally I type something what's in my mind and at a certain character
realise that this or a similar command line should already be in
history and that letting zsh find it should be much faster.

I simply don't understand why the normal "down-line-or-search" only
searches for the first word and not the whole command line. Looks like
nonsense to me...


Thorsten


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

* Re: incremental history search
  2004-02-20 23:04 incremental history search Thorsten Kampe
  2004-02-20 23:20 ` Björn Lindström
@ 2004-02-21  1:17 ` Eric Mangold
  2004-02-21  1:35   ` Thorsten Kampe
  1 sibling, 1 reply; 14+ messages in thread
From: Eric Mangold @ 2004-02-21  1:17 UTC (permalink / raw)
  To: Thorsten Kampe, zsh-users

On Sat, 21 Feb 2004 00:04:00 +0100, Thorsten Kampe 
<thorsten@thorstenkampe.de> wrote:

> I have bound[1] the cursor keys to "up-line-or-search" and
> down-line-or-search. Unfortunately this only completes the first word
> of the search; meaning when I type
>
> wget http://foo.com
> wget ftp://bar.com
>
> and then...
> wget http[up cursor]
> ...it completes to "wget ftp://bar.com" and not to the desired "wget
> http://foo.com". It only searches matches for the first word ("wget")
> of the already typed command line in history.
>
> Is it possible to make zsh search for matches of the whole command
> line ("wget http") - and not only the first word?

Yes. I use the following bindings for that.

bindkey '\M-p' history-beginning-search-backward
bindkey '\M-n' history-beginning-search-forward



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

* Re: incremental history search
  2004-02-21  0:54   ` Thorsten Kampe
@ 2004-02-21  1:19     ` Philippe Troin
  2004-02-21  2:43       ` Thorsten Kampe
  0 siblings, 1 reply; 14+ messages in thread
From: Philippe Troin @ 2004-02-21  1:19 UTC (permalink / raw)
  To: Thorsten Kampe; +Cc: zsh-users

Thorsten Kampe <thorsten@thorstenkampe.de> writes:

> * Björn Lindström (2004-02-21 00:20 +0100)
> > Thorsten Kampe <thorsten@thorstenkampe.de> writes:
> >> Is it possible to make zsh search for matches of the whole command
> >> line ("wget http") - and not only the first word?
> > 
> > Have you tried C-r and C-s?
> 
> C-s just freezes the display and can be unlocked by C-q.

setopt noflowcontrol

Phil.


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

* Re: incremental history search
  2004-02-21  1:17 ` Eric Mangold
@ 2004-02-21  1:35   ` Thorsten Kampe
  2004-02-21  3:07     ` Eric Mangold
  0 siblings, 1 reply; 14+ messages in thread
From: Thorsten Kampe @ 2004-02-21  1:35 UTC (permalink / raw)
  To: zsh-users

* Eric Mangold (2004-02-21 02:17 +0100)
> On Sat, 21 Feb 2004 00:04:00 +0100, Thorsten Kampe 
> <thorsten@thorstenkampe.de> wrote:
>> I have bound[1] the cursor keys to "up-line-or-search" and
>> down-line-or-search. Unfortunately this only completes the first word
>> of the search; meaning when I type
>>
>> wget http://foo.com
>> wget ftp://bar.com
>>
>> and then...
>> wget http[up cursor]
>> ...it completes to "wget ftp://bar.com" and not to the desired "wget
>> http://foo.com". It only searches matches for the first word ("wget")
>> of the already typed command line in history.
>>
>> Is it possible to make zsh search for matches of the whole command
>> line ("wget http") - and not only the first word?
> 
> Yes. I use the following bindings for that.
> 
> bindkey '\M-p' history-beginning-search-backward
> bindkey '\M-n' history-beginning-search-forward

Aah, seems like exactly what I want. Are there any functional
disadvantages compared to "up-line-or-search"/"down-line-or-search"
(because it seems to me as "history-beginning-search-backward" is a
superset of "up-line-or-search")?

Thorsten


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

* Re: incremental history search
  2004-02-21  1:19     ` Philippe Troin
@ 2004-02-21  2:43       ` Thorsten Kampe
  0 siblings, 0 replies; 14+ messages in thread
From: Thorsten Kampe @ 2004-02-21  2:43 UTC (permalink / raw)
  To: zsh-users

* Philippe Troin (2004-02-21 02:19 +0100)
> Thorsten Kampe <thorsten@thorstenkampe.de> writes:
>> * Björn Lindström (2004-02-21 00:20 +0100)
>>> Thorsten Kampe <thorsten@thorstenkampe.de> writes:
>>>> Is it possible to make zsh search for matches of the whole command
>>>> line ("wget http") - and not only the first word?
>>> 
>>> Have you tried C-r and C-s?
>> 
>> C-s just freezes the display and can be unlocked by C-q.
> 
> setopt noflowcontrol

Thanks. I never knew what this "flowcontrol" stuff was for and it
always bothered me when I accidentally hit C-s.

Thorsten


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

* Re: incremental history search
  2004-02-21  1:35   ` Thorsten Kampe
@ 2004-02-21  3:07     ` Eric Mangold
  2004-02-21 13:52       ` Thorsten Kampe
  0 siblings, 1 reply; 14+ messages in thread
From: Eric Mangold @ 2004-02-21  3:07 UTC (permalink / raw)
  To: Thorsten Kampe, zsh-users

On Sat, 21 Feb 2004 02:35:14 +0100, Thorsten Kampe 
<thorsten@thorstenkampe.de> wrote:

> * Eric Mangold (2004-02-21 02:17 +0100)
>> On Sat, 21 Feb 2004 00:04:00 +0100, Thorsten Kampe
>> <thorsten@thorstenkampe.de> wrote:
>>> I have bound[1] the cursor keys to "up-line-or-search" and
>>> down-line-or-search. Unfortunately this only completes the first word
>>> of the search; meaning when I type
>>>
>>> wget http://foo.com
>>> wget ftp://bar.com
>>>
>>> and then...
>>> wget http[up cursor]
>>> ...it completes to "wget ftp://bar.com" and not to the desired "wget
>>> http://foo.com". It only searches matches for the first word ("wget")
>>> of the already typed command line in history.
>>>
>>> Is it possible to make zsh search for matches of the whole command
>>> line ("wget http") - and not only the first word?
>>
>> Yes. I use the following bindings for that.
>>
>> bindkey '\M-p' history-beginning-search-backward
>> bindkey '\M-n' history-beginning-search-forward
>
> Aah, seems like exactly what I want. Are there any functional
> disadvantages compared to "up-line-or-search"/"down-line-or-search"
> (because it seems to me as "history-beginning-search-backward" is a
> superset of "up-line-or-search")?

I can't think of any disadvantages, but the authoritative place to look
is chapter 17.6.2 @ http://zsh.sunsite.dk/Doc/Release/zsh_17.html

	-Eric




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

* Re: incremental history search
  2004-02-21  3:07     ` Eric Mangold
@ 2004-02-21 13:52       ` Thorsten Kampe
  2004-02-21 14:39         ` Anthony Iano-Fletcher
  0 siblings, 1 reply; 14+ messages in thread
From: Thorsten Kampe @ 2004-02-21 13:52 UTC (permalink / raw)
  To: zsh-users

* Eric Mangold (2004-02-21 04:07 +0100)
> On Sat, 21 Feb 2004 02:35:14 +0100, Thorsten Kampe 
> <thorsten@thorstenkampe.de> wrote:
>> * Eric Mangold (2004-02-21 02:17 +0100)
>>> On Sat, 21 Feb 2004 00:04:00 +0100, Thorsten Kampe
>>> <thorsten@thorstenkampe.de> wrote:
>>>> I have bound[1] the cursor keys to "up-line-or-search" and
>>>> down-line-or-search. Unfortunately this only completes the first word
>>>> of the search; meaning when I type
>>>>
>>>> wget http://foo.com
>>>> wget ftp://bar.com
>>>>
>>>> and then...
>>>> wget http[up cursor]
>>>> ...it completes to "wget ftp://bar.com" and not to the desired "wget
>>>> http://foo.com". It only searches matches for the first word ("wget")
>>>> of the already typed command line in history.
>>>>
>>>> Is it possible to make zsh search for matches of the whole command
>>>> line ("wget http") - and not only the first word?
>>>
>>> Yes. I use the following bindings for that.
>>>
>>> bindkey '\M-p' history-beginning-search-backward
>>> bindkey '\M-n' history-beginning-search-forward
>>
>> Aah, seems like exactly what I want. Are there any functional
>> disadvantages compared to "up-line-or-search"/"down-line-or-search"
>> (because it seems to me as "history-beginning-search-backward" is a
>> superset of "up-line-or-search")?
> 
> I can't think of any disadvantages, [...]

Hm, now the cursor stays at the beginning of the command line when I
haven't typed anything and press the up cursor - contrary to the
movement to the end of the command line with "up-line-or-search".
Probably because of the missing "up-line" functionality.

It's a bit of a nuisance because I more often change things at the end
of a command line than at the beginning but I think the extra
functionality of "history-beginning-search-backward" makes it a gain
for me though.

Thorsten


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

* Re: incremental history search
  2004-02-21 13:52       ` Thorsten Kampe
@ 2004-02-21 14:39         ` Anthony Iano-Fletcher
  2004-02-21 15:50           ` Thorsten Kampe
  0 siblings, 1 reply; 14+ messages in thread
From: Anthony Iano-Fletcher @ 2004-02-21 14:39 UTC (permalink / raw)
  To: zsh-users

Hello 

history-beginning-search-backward and history-beginning-search-forward
were designed to repeatedly match whatever was to the left of the cursor
with one's history. The cursor shouldn't move or else a repeated match
would not be looking for the original prefix.

For example, suppose you have this in your history:

	lspci
	uname -a
	lsmod
	date
	ls

If you type 'l<\M-p>' where \M-p is bound to
history-beginning-search-backward then you will get successively
ls, then lsmod and then lspci. Very useful if you want to choose from
any of your history that starts with an 'l'. By the way, the search
prefix is not just the first word - its everything to the left of the
cursor. So one can choose very long commands from a bunch of similar
invocations.

With zsh widgets then you can always combine this search and
end-of-line.

		Anthony.

On 21 Feb 2004 at 14:52:15, Thorsten Kampe wrote:
> * Eric Mangold (2004-02-21 04:07 +0100)
> > On Sat, 21 Feb 2004 02:35:14 +0100, Thorsten Kampe 
> > <thorsten@thorstenkampe.de> wrote:
> >> * Eric Mangold (2004-02-21 02:17 +0100)
> >>> On Sat, 21 Feb 2004 00:04:00 +0100, Thorsten Kampe
> >>> <thorsten@thorstenkampe.de> wrote:
> >>>> I have bound[1] the cursor keys to "up-line-or-search" and
> >>>> down-line-or-search. Unfortunately this only completes the first word
> >>>> of the search; meaning when I type
> >>>>
> >>>> wget http://foo.com
> >>>> wget ftp://bar.com
> >>>>
> >>>> and then...
> >>>> wget http[up cursor]
> >>>> ...it completes to "wget ftp://bar.com" and not to the desired "wget
> >>>> http://foo.com". It only searches matches for the first word ("wget")
> >>>> of the already typed command line in history.
> >>>>
> >>>> Is it possible to make zsh search for matches of the whole command
> >>>> line ("wget http") - and not only the first word?
> >>>
> >>> Yes. I use the following bindings for that.
> >>>
> >>> bindkey '\M-p' history-beginning-search-backward
> >>> bindkey '\M-n' history-beginning-search-forward
> >>
> >> Aah, seems like exactly what I want. Are there any functional
> >> disadvantages compared to "up-line-or-search"/"down-line-or-search"
> >> (because it seems to me as "history-beginning-search-backward" is a
> >> superset of "up-line-or-search")?
> > 
> > I can't think of any disadvantages, [...]
> 
> Hm, now the cursor stays at the beginning of the command line when I
> haven't typed anything and press the up cursor - contrary to the
> movement to the end of the command line with "up-line-or-search".
> Probably because of the missing "up-line" functionality.
> 
> It's a bit of a nuisance because I more often change things at the end
> of a command line than at the beginning but I think the extra
> functionality of "history-beginning-search-backward" makes it a gain
> for me though.
> 
> Thorsten


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

* Re: incremental history search
  2004-02-21 14:39         ` Anthony Iano-Fletcher
@ 2004-02-21 15:50           ` Thorsten Kampe
  2004-02-21 19:00             ` Bart Schaefer
  2004-02-21 23:56             ` Eric Mangold
  0 siblings, 2 replies; 14+ messages in thread
From: Thorsten Kampe @ 2004-02-21 15:50 UTC (permalink / raw)
  To: zsh-users

* Anthony Iano-Fletcher (2004-02-21 15:39 +0100)
> history-beginning-search-backward and history-beginning-search-forward
> were designed to repeatedly match whatever was to the left of the cursor
> with one's history. The cursor shouldn't move or else a repeated match
> would not be looking for the original prefix.

I know that, thanks. I was referring to the *special case where I
haven't typed anything and the command line is empty* and there is
*nothing to search for*. In this case "up-line-or-search" does simply
a "up-line" and moves the cursor to the end of any recalled command
line from history. "history-beginning-search-backward" does a
"up-line", too, in this case, but leaves the cursor where it was (at
the beginning of each recalled command line from history).

Both approaches are useful in certain cases but in my opinion the
dynamic movement to the end of the line is more useful because I
manipulate the end of commands more often than the beginning.

Thorsten


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

* Re: incremental history search
  2004-02-21 15:50           ` Thorsten Kampe
@ 2004-02-21 19:00             ` Bart Schaefer
  2004-03-11 23:50               ` Thorsten Kampe
  2004-02-21 23:56             ` Eric Mangold
  1 sibling, 1 reply; 14+ messages in thread
From: Bart Schaefer @ 2004-02-21 19:00 UTC (permalink / raw)
  To: zsh-users

On Feb 21,  4:50pm, Thorsten Kampe wrote:
}
} Both approaches are useful in certain cases but in my opinion the
} dynamic movement to the end of the line is more useful because I
} manipulate the end of commands more often than the beginning.

See Functions/Zle/history-search-end in the standard distribution.
There's even documentation for it in "man zshcontrib" (the "User
Contributions" section of the info doc).


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

* Re: incremental history search
  2004-02-21 15:50           ` Thorsten Kampe
  2004-02-21 19:00             ` Bart Schaefer
@ 2004-02-21 23:56             ` Eric Mangold
  1 sibling, 0 replies; 14+ messages in thread
From: Eric Mangold @ 2004-02-21 23:56 UTC (permalink / raw)
  To: Thorsten Kampe, zsh-users

On Sat, 21 Feb 2004 16:50:48 +0100, Thorsten Kampe 
<thorsten@thorstenkampe.de> wrote:

> * Anthony Iano-Fletcher (2004-02-21 15:39 +0100)
>> history-beginning-search-backward and history-beginning-search-forward
>> were designed to repeatedly match whatever was to the left of the cursor
>> with one's history. The cursor shouldn't move or else a repeated match
>> would not be looking for the original prefix.
>
> I know that, thanks. I was referring to the *special case where I
> haven't typed anything and the command line is empty* and there is
> *nothing to search for*.

If I just want to move up or down sequentially I use C-p and C-n. I guess 
you need emacs bindings on for this (bindkey -me). These commands do 
position the cursor at the end of the line.

> In this case "up-line-or-search" does simply
> a "up-line" and moves the cursor to the end of any recalled command
> line from history. "history-beginning-search-backward" does a
> "up-line", too, in this case, but leaves the cursor where it was (at
> the beginning of each recalled command line from history).
>
> Both approaches are useful in certain cases but in my opinion the
> dynamic movement to the end of the line is more useful because I
> manipulate the end of commands more often than the beginning.
>
> Thorsten
>



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

* Re: incremental history search
  2004-02-21 19:00             ` Bart Schaefer
@ 2004-03-11 23:50               ` Thorsten Kampe
  0 siblings, 0 replies; 14+ messages in thread
From: Thorsten Kampe @ 2004-03-11 23:50 UTC (permalink / raw)
  To: zsh-users

* Bart Schaefer (2004-02-21 20:00 +0100)
> On Feb 21,  4:50pm, Thorsten Kampe wrote:
> } Both approaches are useful in certain cases but in my opinion the
> } dynamic movement to the end of the line is more useful because I
> } manipulate the end of commands more often than the beginning.
> 
> See Functions/Zle/history-search-end in the standard distribution.
> There's even documentation for it in "man zshcontrib" (the "User
> Contributions" section of the info doc).

Yep, thanks a lot. "up-line-or-beginning-search" (mentioned in "man
zshcontrib" just beneath) is even a little bit more handy than
"history-search-end".

Now, I've bound
"bindkey "\e[A"  history-beginning-search-backward" and
"bindkey "\e[a"  up-line-or-beginning-search" which gives me the
choice with the shift key whether the cursor stays where it is or
moves to the end of the line (because both approaches are better than
the other one sometimes).

But the whole thing makes me a little sad that I don't know more of
this wonderful tool and environment called 'zsh'. It's an universe of
it's own. I read the User's Guide two years ago and still I think that
I know not more than twenty percent of zsh.

If there ever will be a book on zsh, I'll be the first to buy it.

Thorsten


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

end of thread, other threads:[~2004-03-11 23:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-20 23:04 incremental history search Thorsten Kampe
2004-02-20 23:20 ` Björn Lindström
2004-02-21  0:54   ` Thorsten Kampe
2004-02-21  1:19     ` Philippe Troin
2004-02-21  2:43       ` Thorsten Kampe
2004-02-21  1:17 ` Eric Mangold
2004-02-21  1:35   ` Thorsten Kampe
2004-02-21  3:07     ` Eric Mangold
2004-02-21 13:52       ` Thorsten Kampe
2004-02-21 14:39         ` Anthony Iano-Fletcher
2004-02-21 15:50           ` Thorsten Kampe
2004-02-21 19:00             ` Bart Schaefer
2004-03-11 23:50               ` Thorsten Kampe
2004-02-21 23:56             ` Eric Mangold

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