From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24336 invoked from network); 19 Apr 2004 16:24:14 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 19 Apr 2004 16:24:14 -0000 Received: (qmail 17351 invoked by alias); 19 Apr 2004 16:23:49 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7370 Received: (qmail 17340 invoked from network); 19 Apr 2004 16:23:49 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 19 Apr 2004 16:23:49 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.225.247.86] by sunsite.dk (MessageWall 1.0.8) with SMTP; 19 Apr 2004 16:23:48 -0000 Received: (qmail 12856 invoked from network); 19 Apr 2004 16:23:48 -0000 Received: from wbar3.sjo1-4-11-009-147.sjo1.dsl-verizon.net (HELO candle.brasslantern.com) (4.11.9.147) by a.mx.sunsite.dk with SMTP; 19 Apr 2004 16:23:46 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id i3JGNfD10181; Mon, 19 Apr 2004 09:23:41 -0700 X-Authentication-Warning: candle.brasslantern.com: schaefer set sender to schaefer@closedmail.com using -f From: Bart Schaefer Message-Id: <040419092341.ZM10180@candle.brasslantern.com> Date: Mon, 19 Apr 2004 09:23:41 -0700 In-Reply-To: <20040419095235.GA1285@kopfermann.org> Comments: In reply to Matthias Kopfermann "menuselect and history" (Apr 19, 11:52am) References: <20040419095235.GA1285@kopfermann.org> X-Mailer: Z-Mail Lite (5.0.0 30July97) To: Matthias Kopfermann Subject: Re: menuselect and history Cc: zsh-users@sunsite.dk MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: **** X-Spam-Status: No, hits=4.7 required=6.0 tests=RCVD_IN_DYNABLOCK, RCVD_IN_NJABL,RCVD_IN_NJABL_DIALUP,RCVD_IN_SORBS autolearn=no version=2.63 X-Spam-Hits: 4.7 On Apr 19, 11:52am, Matthias Kopfermann wrote: > > i just wondered whether it wouldn't be very cool if menuselect was > useable with historylines. --- 8< --- snip --- 8< --- #compdef -k menu-select ^X: # _history_select -- create a menu-selection of the command history # Works only if invoked on the command word (( CURRENT == 1 )). # Requires 4.2.0 or a recent 4.1.x for the 'n' parameter flag and # array+=string assignments. # BUGS: # This doesn't really scroll through the history, it scrolls # through commands in the history and re-inserts one as the # current history line. So accept-line-and-down-history will # not work as expected, but accept-and-infer-next-history is # probably OK. # TODO: # special case for (( HISTSIZE > 9999 )) # zstyle for how much of the history to include # use the numeric prefix to set the starting point? emulate -L zsh zmodload -i zsh/parameter || return 1 (( CURRENT == 1 )) || return 1 local h c local -a histnos commands displays histnos=(${(Onk)history}) for h in $histnos do c=$history[$h] commands+=$c # Various display bugs require that we trim each selection to fit on # a single line. Use a display that includes the history number. if [[ $#c -gt 71 ]]; then c[72,-1]=...; fi c=${c//$'\n'*/ ...} displays+=${(r:5:)${(l:4:)h}}$c done compadd -Q -l -V commands -d displays -a commands --- 8< --- snip --- 8< ---