zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-users@sunsite.dk
Subject: Re: another (hopefully simple) completion question
Date: Tue, 14 Feb 2006 22:34:28 +0000	[thread overview]
Message-ID: <200602142234.k1EMYSwp003464@pwslaptop.csr.com> (raw)
In-Reply-To: Message from William Scott <wgscott@chemistry.ucsc.edu>  of "Tue, 14 Feb 2006 07:22:15 PST." <190A02D8-976A-48E9-B129-E678764BE811@chemistry.ucsc.edu>

William Scott wrote:
> Is there a simple way to complete with the sort order governed by  
> most recently touched file first (the order ls -t produces) rather  
> than the conventional order?  Ideally I'd like to bind it to ctl-tab  
> or some such key combo and retain the normal completion option with tab.

Yes, you can do this very flexibly just using styles.  The following is
the solution explained by Oliver in From Bash to Z Shell (Apress, ISBN
1-59059-376-6), page 407.  The _generic widget is really just a hook so
you can hang a special name on it, using styles to make it do something
different from normal completion.

# Use menu completion to cycle through files.
zle -C most-recent-file menu-complete _generic
# Use file completion, but add the _match completer so
# glob patterns can be used.
zstyle 'completion:most-recent-file::::' completer _menu _files _match
# Use the file-sort style to sort in modification time order.
zstyle ':completion:most-recent-file:*' file-sort modification
# We don't want to see the list of matches, just the results.
zstyle ':completion:most-recent-file:*' hidden all
# Optionally, restrict matches to regular files
zstyle ':completion:most-recent-file:*' file-patterns '*(.):normal\ files'
# Bind the widget.
bindkey '^X.' most-recent-file

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page still at http://www.pwstephenson.fsnet.co.uk/


  reply	other threads:[~2006-02-14 22:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <wgscott@chemistry.ucsc.edu>
2006-02-14 15:22 ` William Scott
2006-02-14 22:34   ` Peter Stephenson [this message]
2006-02-15  0:51     ` William Scott
2005-12-09 15:32 zsh 4.3.0-dev-2 Peter Stephenson
2005-12-10  3:48 ` William Scott
2005-12-10 16:03   ` Peter Stephenson
2005-12-10 16:27     ` Peter Stephenson

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=200602142234.k1EMYSwp003464@pwslaptop.csr.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-users@sunsite.dk \
    /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).