Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: MIME and completion ?
- X-seq: zsh-users 13795
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: MIME and completion ?
- Date: Sat, 31 Jan 2009 13:21:28 -0800
- In-reply-to: <9f18d39e0901300157n3f01cd39p266a30232a31b073@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <9f18d39e0901300157n3f01cd39p266a30232a31b073@xxxxxxxxxxxxxx>
On Jan 30, 10:57am, Sylvain Meunier wrote:
}
} I would use MIME types with the zsh completion system when i use
} wildcards like * or ? for ignoring "uneditable" files.
First you need to describe the syntax of the file from which you
are obtaining your MIME type data. ~/.mailcap and ~/.mime.types
have radically different formats, and there are probably some XML
files that describe MIME floating around as well. For example, to
get all the file extensions for text files out of /etc/mime.types
you can use this parameter expansion:
${=${(M)${(f)"$(</etc/mime.types)"}:#text/*[[:space:]]*}#*[[:space:]]}
To break that down ...
mime_types=( ${(f)"$(</etc/mime.types)"} )
text_types=( ${(M)mime_types:#text/*[[:space:]]*} )
text_exts=( ${=text_types#*[[:space:]]} )
You probably want to add some things to that for which there are not
entries in /etc/mime.types, such as:
text_exts+=(c h sh)
Then you need to create zstyle entries for the commands to which
each MIME type applies. Probably you want the ignored-patterns
style, which means you need to list the files you DO NOT want to
match. Since extendedglob is on during completion, you can do
that by making a negated pattern (a leading caret, with the rest
of the pattern in parens). Example:
zstyle ':completion::complete:(vi|vim):*' ignored-patterns \
"^(*.(${(j:|:)text_exts}))"
Rinse and repeat for other types and commands.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author