Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Insert Most Recent File
- X-seq: zsh-users 16379
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Bastien Dejean <eschyle@xxxxxxxxx>
- Subject: Re: Insert Most Recent File
- Date: Sat, 17 Sep 2011 12:53:04 +0200
- Cc: ZSH Users Mailing List <zsh-users@xxxxxxx>
- 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=
- In-reply-to: <20110917103254.GA10435@circle.home>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20110917103254.GA10435@circle.home>
On 17 September 2011 12:32, Bastien Dejean <eschyle@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author