zsh-users
 help / color / mirror / code / Atom feed
* Insert Most Recent File
@ 2011-09-17 10:32 Bastien Dejean
  2011-09-17 10:53 ` Mikael Magnusson
  0 siblings, 1 reply; 2+ messages in thread
From: Bastien Dejean @ 2011-09-17 10:32 UTC (permalink / raw)
  To: ZSH Users Mailing List

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?

Cheers,
-- 
Bastien


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Insert Most Recent File
  2011-09-17 10:32 Insert Most Recent File Bastien Dejean
@ 2011-09-17 10:53 ` Mikael Magnusson
  0 siblings, 0 replies; 2+ messages in thread
From: Mikael Magnusson @ 2011-09-17 10:53 UTC (permalink / raw)
  To: Bastien Dejean; +Cc: ZSH Users Mailing List

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-17 10:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-17 10:32 Insert Most Recent File Bastien Dejean
2011-09-17 10:53 ` Mikael Magnusson

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).