From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23330 invoked by alias); 10 Jan 2015 20:30:48 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19725 Received: (qmail 8230 invoked from network); 10 Jan 2015 20:30:46 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=6i5MZA20vZdCUuLGMYj8LZRXTV5GSnZ/+TxqGbGWEho=; b=AJYuJCf+SIDRXwnNfZmE1jzTRHS55EaRoxusiTz5sLPTTbcgA7YeIX+D1qJgRGMy5r aXfHg4t+uf+jQSeqMgC5LNvBVEiZ20PYz164nvrywaF7d4Nk0TNxYADUl/MqHlTv/PNJ ptapg67d4xyWAi5myb78G0WAw2uh/co5U7xRLSUm6GPJ+voSy5/hsXOoDyomPAzL+0DG yIvNu1LrUeQJsREepXwBqvhczkiuclLstMY7EAwxjw12ubY0Vm8y8b3m6OYuaLU9g583 4Xr/uM0gC9w5aXHqscicnKFbWYMTPulN0MUnIzf+coaU8xfz+qGPTj1e2ZqY/nHfuATb v8Cg== MIME-Version: 1.0 X-Received: by 10.42.25.144 with SMTP id a16mr18740605icc.66.1420921845087; Sat, 10 Jan 2015 12:30:45 -0800 (PST) In-Reply-To: <20150110201100.61b16d41@ntlworld.com> References: <20150110201100.61b16d41@ntlworld.com> Date: Sat, 10 Jan 2015 21:30:45 +0100 Message-ID: Subject: Re: tab completion sort by modification time From: Mikael Magnusson To: Peter Stephenson Cc: kamaraju kusumanchi , Zsh Users Content-Type: text/plain; charset=UTF-8 On Sat, Jan 10, 2015 at 9:11 PM, Peter Stephenson wrote: > On Sat, 10 Jan 2015 14:33:49 -0500 > kamaraju kusumanchi wrote: >> Long time bash user here. Looking to see if zsh can solve my >> particular problem. If it does, I'd like to switch to it. >> >> Say a directory contains a lot of files and say I am only interested >> in the files that were recently edited/created. When doing a tab >> completion inside this directory, I would like the files to be listed >> in the order of modification time (similar to ls -rt). This way the >> latest files show up at the end and I can easily copy/paste their >> names using mouse onto the command line. >> >> Is zsh tab completion system comprehensive enough to do something like this? > > I'm assuming as a bash user you're not subscribed to zsh-users... > > If you want this behaviour globally, I think it's as simple as the > following piece of configuration: > > zstyle ':completion:*' file-sort modification > > If you want more control, reading the zshcompsys manual page should give > you ideas of how to modify that first argument --- which is a pattern > matching the context in which a completion occurs --- should give you > some ideas how to do so. > > It's also relatively straightforward (i.e someone here can work out > how to do it in a few minutes after you've scratched your head for > half an hour:-)) to add a new key binding that has this file completion > behaviour. As it happens, I have one of these lying around already (I'm 83% sure you wrote this for me too), zstyle ':completion:most-recent-file:*' match-original both zstyle ':completion:most-recent-file:*' file-sort modification zstyle ':completion:most-recent-file:*' file-patterns '*:all\ files' zstyle ':completion:most-recent-file:*' hidden all zstyle ':completion:most-recent-file:*' completer _files zle -C most-recent-file menu-complete _generic bindkey "^N" most-recent-file -- Mikael Magnusson