From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11810 invoked by alias); 17 Sep 2011 10:53:14 -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: 16379 Received: (qmail 25668 invoked from network); 17 Sep 2011 10:53:13 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) 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.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.212.41 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=nPsShgKskQcPW3983FMPP3q/kPNPLzym26nDtYm1Fpw=; b=SV/LgzjcBzsY25CYH2WCzvymUB3alUPpWwDTYOZOxrwE2ScXYG4zywU4eKg6U0J0Lc DoqSMsZa1+HnI5NVo8gyxDyUyaFY+l1vUddqb5iPd33yJc2lqEX/cdmkF7+il6JMG3+8 ClA9ZBcekAiwBslyJXVQ8xtB0yqjnUQLz1tqU= MIME-Version: 1.0 In-Reply-To: <20110917103254.GA10435@circle.home> References: <20110917103254.GA10435@circle.home> Date: Sat, 17 Sep 2011 12:53:04 +0200 Message-ID: Subject: Re: Insert Most Recent File From: Mikael Magnusson To: Bastien Dejean Cc: ZSH Users Mailing List Content-Type: text/plain; charset=UTF-8 On 17 September 2011 12:32, Bastien Dejean wrote: > Hi, > > I noticed that the _most_recent_file widget doesn't necessarily return > the most recent file (to me, it should be `ls -tc | head -1`). > > Is there a way to configure this widget to enforce the expected behavior? -tc means ctime, which is the time the status of the file changed (ie permissions and ownership), -t means mtime which is the last time the actual contents of the file were changed. So I would expect something that gets the recent file to use the mtime, which is what zsh does do (ctime is always equal to or later than mtime though, afaik, unless someone fiddled with the value manually). To answer your question however, you can't configure the _most_recent_file widget to do this, it has (om) written in it, it would have to be (oc) to use ctime. I have this configuration which defines two widgets that complete sorting on mtime and atime respectively, 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 zstyle ':completion:most-accessed-file:*' match-original both zstyle ':completion:most-accessed-file:*' file-sort access zstyle ':completion:most-accessed-file:*' file-patterns '*:all\ files' zstyle ':completion:most-accessed-file:*' hidden all zstyle ':completion:most-accessed-file:*' completer _files zle -C most-accessed-file menu-complete _generic if you use 'change' or 'inode' for the file-sort style, it will use ctime for sorting. Then you just need to bindkey '^whatever' most-recent-file to use it. -- Mikael Magnusson