Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Standard 'filtering' mechanism?
- X-seq: zsh-users 14834
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Standard 'filtering' mechanism?
- Date: Sun, 14 Feb 2010 20:54:59 +0000
- In-reply-to: Message from "Benjamin R. Haskell" <zsh@xxxxxxxxxx> of "Sun, 14 Feb 2010 15:05:17 EST." <alpine.LNX.2.01.1002141420590.2729@xxxxxxxxxxx>
- 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
"Benjamin R. Haskell" wrote:
> I'm still getting acquainted with the intricacies of Zsh completion and
> pattern matching. One thing I've wanted to do for a while is prevent
> 'vim' completion from matching the various 'junk' files that are
> associated with various phases of TeX compilation.
If I've worked out correctly what you're trying to do (exclude files
which have the same basename as a .tex file), how about something like
this...
vim-files() {
local dir
if [[ $PREFIX = */* ]]; then
if [[ $PREFIX[-1] = / ]]; then
dir=$PREFIX[1,-2]
else
dir=${PREFIX:h}
fi
else
dir=.
fi
local -a texfiles nontexfiles
local -aU suffixes
texfiles=($dir/*.tex(N))
if (( $#texfiles )); then
notexfiles=(${texfiles:r}.*)
suffixes=(${${notexfiles:e}:#tex})
reply=("^*.(${(j.|.)suffixes})")
fi
}
zstyle -e ':completion:*:*:vim:*' file-patterns vim-files
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author