Zsh Mailing List Archive
Messages sorted by:
Re: Line editor - "get word from history"
- X-seq: zsh-workers 4689
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>
- To: Paul Moore <gustav@xxxxxxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxxxxxxxxxx
- Subject: Re: Line editor - "get word from history"
- Date: Thu, 26 Nov 1998 09:47:47 +0100
- In-reply-to: "Paul Moore"'s message of "Wed, 25 Nov 1998 23:15:35 NFT." <19981125231534.A735@morpheus>
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
> 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
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
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@xxxxxxxxxxxxxxxxx> Tel: +39 050 844536
Dipartimento di Fisica, Via Buonarroti 2, 56100 Pisa, Italy
Messages sorted by: