zsh-users
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: kamaraju kusumanchi <raju.mailinglists@gmail.com>,
	Zsh Users <zsh-users@zsh.org>
Subject: Re: tab completion sort by modification time
Date: Sat, 10 Jan 2015 21:30:45 +0100	[thread overview]
Message-ID: <CAHYJk3SNfE9eW4bN6XUwcF0tGoagTsVHAEjMNEZXSf8Ni2u-tg@mail.gmail.com> (raw)
In-Reply-To: <20150110201100.61b16d41@ntlworld.com>

On Sat, Jan 10, 2015 at 9:11 PM, Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:
> On Sat, 10 Jan 2015 14:33:49 -0500
> kamaraju kusumanchi <raju.mailinglists@gmail.com> 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


  reply	other threads:[~2015-01-10 20:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-10 19:33 kamaraju kusumanchi
2015-01-10 19:52 ` Eric Cook
2015-01-11  4:40   ` kamaraju kusumanchi
2015-01-12  5:58     ` kamaraju kusumanchi
2015-01-10 20:11 ` Peter Stephenson
2015-01-10 20:30   ` Mikael Magnusson [this message]
2015-01-10 22:08     ` kamaraju kusumanchi

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=CAHYJk3SNfE9eW4bN6XUwcF0tGoagTsVHAEjMNEZXSf8Ni2u-tg@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=p.w.stephenson@ntlworld.com \
    --cc=raju.mailinglists@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).