Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: completer that first expands global aliases (Re: dsf)
- X-seq: zsh-users 17537
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Daniel <quite@xxxxxxxx>, "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
- Subject: Re: completer that first expands global aliases (Re: dsf)
- Date: Tue, 8 Jan 2013 13:06:27 +0000 (GMT)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1357650387; bh=wZbS+c4j8X5As6I2xB5CTTe6kZVSHmSXgYv0XPhwWMk=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=CxllMcglW4+nbZyaUbwZ+xJEkpJBI/aZA/kcTsC9RNPw0uyFl68/CoiQwKgvFSa/jYO6K53X5gMX3yo+bDozTmea2f3zna/CX8RBaSnrmh7YHZb52bDm6f6f2c5kLKvtFgVIUjXzDeY440IuYt9ZNvLW/A5jIAE3r7bzapvPYN8=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=W3BxvTv30euios4OBhUUyGnayPSRv8E8V5D+wp1PaOVBZbIHreURSPwCEk3wzdViJ7HtMKucGLXSCq8qESgP/m+1HbaRfSmaiYIpzubCEcPNeC/hoaxWquc57epY9/hf68iqbyIin5rdf1aYCienXpgSRQzSG5C48f/OoV9Ss5I=;
- In-reply-to: <kcgpl3$dec$1@ger.gmane.org>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <kce6de$35t$1@ger.gmane.org> <kcgpl3$dec$1@ger.gmane.org>
- Reply-to: Oliver Kiddle <okiddle@xxxxxxxxxxx>
Daniel wrote:
> I have a nice little recent-files completer, see below.
> (found here: http://michael.stapelberg.de/Artikel/zsh_recent_completion )
>
> What I would like to add to this, is for it to expand global aliases inline,
> before trying to complete (and thus ending up completing files in my aliased
> directory).
>
> I started trying to meld _generic and _expand_alias, but with my lack of
> fluency in zsh, I just made a mess :) Any help out there? Is there perhaps some
> zstyle ':completion:newest-files:*' completer _files
You can insert _expand_alias before _files in the list of completer
functions. I'm not sure if that works in the way you want: a global
alias will simply be expanded. If you tried that and it didn't work then
I would suspect that your default completer style is getting precedence
over this one. Try using more colons instead of a *:
zstyle ':completion:newest-files::::' completer _expand_alias _files
If this doesn't behave in the way you would like, perhaps give us some
examples of your global aliases and what you behaviour you would like.
> zstyle ':completion:newest-files:*' file-patterns '*~.*(omN[1,12])'
> zstyle ':completion:newest-files:*' menu select yes
> zstyle ':completion:newest-files:*' sort false
> zstyle ':completion:newest-files:*' matcher-list 'b:=*' # important
I do this in a somewhat different way. The comment on the last line
isn't particularly helpful. It makes matching use substrings so for
example typing
ls pdf<Ctrl-X>r
will match *pdf* in order of file modification. Note that matching is
done after the globbing so if you have more than 12 newer files than any
of the matching ones, you won't get anything.
I use _match instead so if I want the most recent PDF file, I complete
after *.pdf. I also need the match-original style set for that to work.
I can't think of a different way to limit the number of matches to 12. I
simply turn off completion listing for the widget and it is rare that I
need to cycle through more than a couple of matches. This also has the
advantage that you can invoke reverse-menu-complete to get the oldest
file (which is sometimes useful).
I use the following:
zstyle ':completion:most-recent-*::::' completer _menu _files _match
zstyle ':completion:most-recent-*:*' file-sort modification
zstyle ':completion:most-recent-*:*' hidden all
zstyle ':completion:(match-word|most-recent-*):*' match-original both
zstyle ':completion:most-recent-file:*' file-patterns '*(.):normal\ files'
zstyle ':completion:most-recent-dir:*' file-patterns '*(/):directories'
bindkey '^Xm' most-recent-file
bindkey '^XM' most-recent-dir
zle -C most-recent-file menu-complete _generic
zle -C most-recent-dir menu-complete _generic
Note that I have a separate widget for directories. You may also want to
experiment with using _complete instead of _files to make it more
intelligent, at least in theory:
zstyle ':completion:most-recent-*::::' completer _menu _complete _match
zstyle ':completion:most-recent-file:*' file-patterns '%p(N):globbed-files'
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author