zsh-users
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Bastien Dejean <eschyle@gmail.com>
Cc: ZSH Users Mailing List <zsh-users@zsh.org>
Subject: Re: Insert Most Recent File
Date: Sat, 17 Sep 2011 12:53:04 +0200	[thread overview]
Message-ID: <CAHYJk3T_3+L5XRNMziVn4qHhX3LkfmRVKnh=uaPcmNaOAOW1Mg@mail.gmail.com> (raw)
In-Reply-To: <20110917103254.GA10435@circle.home>

On 17 September 2011 12:32, Bastien Dejean <eschyle@gmail.com> 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


      reply	other threads:[~2011-09-17 10:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-17 10:32 Bastien Dejean
2011-09-17 10:53 ` Mikael Magnusson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHYJk3T_3+L5XRNMziVn4qHhX3LkfmRVKnh=uaPcmNaOAOW1Mg@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=eschyle@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).