From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12898 invoked from network); 17 Aug 2002 03:49:31 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 17 Aug 2002 03:49:31 -0000 Received: (qmail 22986 invoked by alias); 17 Aug 2002 03:49:15 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5261 Received: (qmail 22973 invoked from network); 17 Aug 2002 03:49:14 -0000 From: "Bart Schaefer" Message-Id: <1020817034844.ZM2957@candle.brasslantern.com> Date: Sat, 17 Aug 2002 03:48:43 +0000 In-Reply-To: Comments: In reply to "history menu completion?" (Aug 16, 6:51pm) References: X-Mailer: Z-Mail (5.0.0 30July97) To: , Subject: Re: history menu completion? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Aug 16, 6:51pm, wrote: } } $ !somecom } } 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 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