Linux command
zstyle 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Define a style
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
List all
zstyle -L
List styles
zstyle -L ':completion:*'
Delete a style
zstyle -d ':completion:*' menu
Look up a style
zstyle -s ':completion:*' completer REPLY
Look up a style
zstyle -a ':completion:*:descriptions' format DESCR
Test a boolean style
zstyle -t ':completion:*' verbose
Define a dynamically-evaluated
zstyle -e ':completion:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'
说明
zstyle is a builtin from the zsh/zutil module used to define and look up styles. A style is a name/value pair stored against a pattern; lookups supply a colon-separated context string that is matched against those patterns. The most specific matching pattern wins. Pattern specificity is determined by the number of colon-separated components and how literal each component is. Literal strings beat patterns, complex patterns beat the wildcard `*`, and ties are broken in favor of the pattern defined first. A `*` matches any number of characters including colons. Styles are most prominently used by zsh's shell-function-based completion system, where contexts follow the form :completion:_function_:_completer_:_command_:_argument_:_tag_. They are also used by prompt themes (e.g. vcs_info), zsh plugins, and arbitrary user code that calls zstyle -s/-a/-b/-t to read user preferences.
参数
- -L _metapattern_ [_style_]
- List style definitions as zstyle commands. Optional _metapattern_ filters by pattern, _style_ filters by style name.
- -e
- Treat the value as code to be evaluated when the style is looked up; the parameter reply must be set to the resulting strings.
- -d _pattern_ [_style_ ...]
- Delete styles. Without arguments deletes all definitions. With a _pattern_, deletes that pattern; with _styles_, deletes only those.
- -g _name_ _pattern_ [_style_]
- Get definitions into the array _name_. Returns patterns, styles for a pattern, or values for a (pattern, style) pair.
- -s _context_ _style_ _name_ _sep_
- Read the style as a scalar into _name_, joining multiple values with spaces or _sep_. Returns 0 if set, 1 otherwise.
- -b _context_ _style_ _name_
- Read the style as a boolean (`yes` if the single value is yes, true, on, or 1; otherwise `no`).
- -a _context_ _style_ _name_
- Read the style as an array; if _name_ is associative, alternate strings become keys and values.
- -t _context_ _style_ _string_ ...
- Test a style. Status 0 = matches/true, 1 = defined but not matching, 2 = undefined.
- -T _context_ _style_ _string_ ...
- Like -t but returns 0 (instead of 2) when the style is undefined for any matching pattern.
- -m _context_ _style_ _pattern_
- Pattern-match a style value. Returns 0 if _pattern_ matches at least one of the value's strings.
FAQ
What is the zstyle command used for?
zstyle is a builtin from the zsh/zutil module used to define and look up styles. A style is a name/value pair stored against a pattern; lookups supply a colon-separated context string that is matched against those patterns. The most specific matching pattern wins. Pattern specificity is determined by the number of colon-separated components and how literal each component is. Literal strings beat patterns, complex patterns beat the wildcard `*`, and ties are broken in favor of the pattern defined first. A `*` matches any number of characters including colons. Styles are most prominently used by zsh's shell-function-based completion system, where contexts follow the form :completion:_function_:_completer_:_command_:_argument_:_tag_. They are also used by prompt themes (e.g. vcs_info), zsh plugins, and arbitrary user code that calls zstyle -s/-a/-b/-t to read user preferences.
How do I run a basic zstyle example?
Run `zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -L _metapattern_ [_style_] do in zstyle?
List style definitions as zstyle commands. Optional _metapattern_ filters by pattern, _style_ filters by style name.