From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16521 invoked from network); 15 Feb 2006 00:51:27 -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; 15 Feb 2006 00:51:27 -0000 Received: (qmail 47223 invoked from network); 15 Feb 2006 00:51:19 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 Feb 2006 00:51:19 -0000 Received: (qmail 1967 invoked by alias); 15 Feb 2006 00:51:11 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9928 Received: (qmail 1956 invoked from network); 15 Feb 2006 00:51:10 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 15 Feb 2006 00:51:10 -0000 Received: (qmail 46043 invoked from network); 15 Feb 2006 00:51:10 -0000 Received: from vanunu.ucsc.edu (128.114.150.22) by a.mx.sunsite.dk with SMTP; 15 Feb 2006 00:51:09 -0000 Received: from localhost (localhost [127.0.0.1]) by vanunu.ucsc.edu (Postfix) with ESMTP id 7230214B4FA2; Tue, 14 Feb 2006 16:51:18 -0800 (PST) Date: Tue, 14 Feb 2006 16:51:18 -0800 (PST) From: William Scott X-X-Sender: wgscott@vanunu.ucsc.edu To: Peter Stephenson Cc: zsh-users@sunsite.dk Subject: Re: another (hopefully simple) completion question In-Reply-To: <200602142234.k1EMYSwp003464@pwslaptop.csr.com> Message-ID: References: <200602142234.k1EMYSwp003464@pwslaptop.csr.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Dear Peter: Sorry to put you through this. Not only do I have the book, I had highlighted the section. Oops. But thanks! Bill On Tue, 14 Feb 2006, Peter Stephenson wrote: > 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/ >