zsh-workers
 help / color / mirror / code / Atom feed
* Line editor - "get word from history"
@ 1998-11-25 23:15 Paul Moore
  1998-11-26  8:47 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Moore @ 1998-11-25 23:15 UTC (permalink / raw)
  To: zsh-workers

I was reading an article on the WWW recently, which compared various
shells. One feature of tcsh which was commented on favourably was the
history stuff. Two particular features I liked:

1. A keypress to move to a previous history line which matched what you
had typed so far on the line. Zsh has this, in history-beginning-search-
backward (although I'd prefer this if it moved the cursor to the end of
the line, but retained knowledge of the part I had typed, so that I
could continue backwards matching what I had typed, or stop and add to
the end of the line).

2. A keypress to complete the current word, using the words in previous
history lines - imagine 
    mkdir a-very-long-name
    cd a-<complete>

I looked in the zsh documentation I have (not totally up-to-date) and
could find nothing like (2). Is it available in the latest version, and
if not, is there any chance of it being added?

Thanks,
Paul Moore.


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

* Re: Line editor - "get word from history"
  1998-11-25 23:15 Line editor - "get word from history" Paul Moore
@ 1998-11-26  8:47 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 1998-11-26  8:47 UTC (permalink / raw)
  To: Paul Moore, zsh-workers

Paul Moore wrote:
> I was reading an article on the WWW recently, which compared various
> shells. One feature of tcsh which was commented on favourably was the
> history stuff. Two particular features I liked:
> 
> 1. A keypress to move to a previous history line which matched what you
> had typed so far on the line. Zsh has this, in history-beginning-search-
> backward (although I'd prefer this if it moved the cursor to the end of
> the line, but retained knowledge of the part I had typed, so that I
> could continue backwards matching what I had typed, or stop and add to
> the end of the line).

There's a long and involved story to this.  The end of the story is
that zsh had this, but it was removed because it seemed to be one too
many special cases in the Zle code.  The dust has not yet quite
settled.  Frankly, having seen all the discussion, I think the path of
least resistance is to put it back in some form.

Having converted myself, I can say, however, that when you get used to
it not going to the end of the line you may wonder why you ever wanted
it to.

> 2. A keypress to complete the current word, using the words in previous
> history lines - imagine 
>     mkdir a-very-long-name
>     cd a-<complete>
> 
> I looked in the zsh documentation I have (not totally up-to-date) and
> could find nothing like (2). Is it available in the latest version, and
> if not, is there any chance of it being added?

It's not there as such in an official version yet, but there are two
notes to be made (three notes to be made, among the notes to be made
are):

1. there are better ways of completing directory names in both tcsh
and zsh, but I presume that was just a random example.

2. you can in all recent zsh add history matching to default
completion (or any other sort) by sticking + -H 0 '' on the end,
e.g. (simplest case):
  compctl -D -f + -H 0 ''
so if it doesn't find a file it'll search the history list.

3. there is a patch which allows you to bind arbitrary completions to
particular keys.  If you're desperate to try it, there's an unofficial
(and definitely beta, though apparently usable) version which contains
it which you can get at
http://www.ifh.de/~pws/computing/zsh-3.1.5-patched.tar.gz .
Then the incantation is
  zle -C history-complete-word -H 0 ''
  bindkey "your-favourite-key-sequence" history-complete-word
This method works for any set of completions, not just history.  The
semantics may change if this patch becomes official.

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56100 Pisa, Italy


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

end of thread, other threads:[~1998-11-26  9:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-25 23:15 Line editor - "get word from history" Paul Moore
1998-11-26  8:47 ` Peter Stephenson

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