From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3533 invoked from network); 14 Feb 2006 22:35:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 14 Feb 2006 22:35:09 -0000 Received: (qmail 44078 invoked from network); 14 Feb 2006 22:35:00 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 14 Feb 2006 22:35:00 -0000 Received: (qmail 11255 invoked by alias); 14 Feb 2006 22:34:40 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9926 Received: (qmail 11152 invoked from network); 14 Feb 2006 22:34:38 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 14 Feb 2006 22:34:38 -0000 Received: (qmail 40780 invoked from network); 14 Feb 2006 22:34:37 -0000 Received: from mta07-winn.ispmail.ntl.com (81.103.221.47) by a.mx.sunsite.dk with SMTP; 14 Feb 2006 22:34:36 -0000 Received: from aamta12-winn.ispmail.ntl.com ([81.103.221.35]) by mta07-winn.ispmail.ntl.com with ESMTP id <20060214223435.CWZO15056.mta07-winn.ispmail.ntl.com@aamta12-winn.ispmail.ntl.com> for ; Tue, 14 Feb 2006 22:34:35 +0000 Received: from pwslaptop.csr.com ([81.105.238.64]) by aamta12-winn.ispmail.ntl.com with ESMTP id <20060214223435.WWHY12811.aamta12-winn.ispmail.ntl.com@pwslaptop.csr.com> for ; Tue, 14 Feb 2006 22:34:35 +0000 Received: from pwslaptop.csr.com (pwslaptop.csr.com [127.0.0.1]) by pwslaptop.csr.com (8.13.4/8.13.4) with ESMTP id k1EMYU6d003467 for ; Tue, 14 Feb 2006 22:34:30 GMT Received: from pwslaptop.csr.com (pws@localhost) by pwslaptop.csr.com (8.13.4/8.13.4/Submit) with ESMTP id k1EMYSwp003464 for ; Tue, 14 Feb 2006 22:34:30 GMT Message-Id: <200602142234.k1EMYSwp003464@pwslaptop.csr.com> X-Authentication-Warning: pwslaptop.csr.com: pws owned process doing -bs From: Peter Stephenson To: zsh-users@sunsite.dk Subject: Re: another (hopefully simple) completion question In-Reply-To: Message from William Scott of "Tue, 14 Feb 2006 07:22:15 PST." <190A02D8-976A-48E9-B129-E678764BE811@chemistry.ucsc.edu> Date: Tue, 14 Feb 2006 22:34:28 +0000 William Scott wrote: > Is there a simple way to complete with the sort order governed by > most recently touched file first (the order ls -t produces) rather > than the conventional order? Ideally I'd like to bind it to ctl-tab > or some such key combo and retain the normal completion option with tab. Yes, you can do this very flexibly just using styles. The following is the solution explained by Oliver in From Bash to Z Shell (Apress, ISBN 1-59059-376-6), page 407. The _generic widget is really just a hook so you can hang a special name on it, using styles to make it do something different from normal completion. # Use menu completion to cycle through files. zle -C most-recent-file menu-complete _generic # Use file completion, but add the _match completer so # glob patterns can be used. zstyle 'completion:most-recent-file::::' completer _menu _files _match # Use the file-sort style to sort in modification time order. zstyle ':completion:most-recent-file:*' file-sort modification # We don't want to see the list of matches, just the results. zstyle ':completion:most-recent-file:*' hidden all # Optionally, restrict matches to regular files zstyle ':completion:most-recent-file:*' file-patterns '*(.):normal\ files' # Bind the widget. bindkey '^X.' most-recent-file -- Peter Stephenson Web page still at http://www.pwstephenson.fsnet.co.uk/