From: "Bart Schaefer" <schaefer@brasslantern.com>
To: <vts@veritas.uchicago.edu>, <zsh-users@sunsite.dk>
Subject: Re: history menu completion?
Date: Sat, 17 Aug 2002 03:48:43 +0000 [thread overview]
Message-ID: <1020817034844.ZM2957@candle.brasslantern.com> (raw)
In-Reply-To: <Pine.LNX.4.33L2.0208161840130.28906-100000@veritas.uchicago.edu>
On Aug 16, 6:51pm, <vts@veritas.uchicago.edu> wrote:
}
} $ !somecom<TAB>
}
} I'll get the following
}
} $ somecommand -with -more -fancy /options/and/another/long/path
}
} At this point, I would like to be able to hit <TAB> again to get:
}
} $ somecommand -with -fancy /options/and/a/long/path
You're confusing expansion and completion.
When completion is invoked, zsh first attempts history expansion on the
command line. Only if that fails to change anything is actual completion
attempted. (If the keybinding is "expand-or-complete" then the other
expansions -- parameters, file globbing, etc. -- are also tried before
completion.) So the effect you see on the first TAB is expansion, and
the fact that there was a history reference is long forgotten by the
time you hit the second TAB.
It's really not possible to do this any other way, because the number
of different ways to reference the history -- searches with !?pat?, the
word numbers with !:2, etc. -- plus the possibility of having several
different history references on the command line at the same time when
completion is started, make it potentially impossible to "find another
line matching the history references that expanded to give this one."
If what you want is to search the history, you should be using some of
ZLE's many history-search bindings.
You can write your own zle widget that invokes history search when you
press TAB; e.g.:
function history-or-complete {
setopt localoptions noksharrays
typeset -gH __history_completing
if [[ $LBUFFER[1] == '!' ]]
then
LBUFFER[1]=''
local ret=0
if zle history-beginning-search-backward
then
__history_completing=history-beginning-search-backward
else
zle complete-word || ret=$?
LBUFFER='!'"$LBUFFER"
fi
return ret
elif [[ $LASTWIDGET == history-or-complete ]]
then
zle $__history_completing
else
__history_completing=complete-word
zle complete-word
fi
}
zle -N history-or-complete
bindkey '\t' history-or-complete
If this doesn't cut it, try replacing history-beginning-search-backward
with history-search-backward, or whatever other builtin widget does the
thing most like what you want
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
next prev parent reply other threads:[~2002-08-17 3:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-16 23:51 vts
2002-08-17 3:48 ` Bart Schaefer [this message]
2002-08-17 5:01 ` Wayne Davison
2002-08-17 8:50 ` Darren Greaves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1020817034844.ZM2957@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=vts@veritas.uchicago.edu \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).