Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: another (hopefully simple) completion question
- X-seq: zsh-users 9928
- From: William Scott <wgscott@xxxxxxxxxxxxxxxxxx>
- To: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- Subject: Re: another (hopefully simple) completion question
- Date: Tue, 14 Feb 2006 16:51:18 -0800 (PST)
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <200602142234.k1EMYSwp003464@xxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <200602142234.k1EMYSwp003464@xxxxxxxxxxxxxxxxx>
Dear Peter:
Sorry to put you through this. Not only do I have the book, I had
highlighted the section. Oops.
But thanks!
Bill
On Tue, 14 Feb 2006, Peter Stephenson wrote:
> 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@xxxxxxxxxxxx>
> Web page still at http://www.pwstephenson.fsnet.co.uk/
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author