我在 zsh 中发现了以下两个片段:
片段 1:
autoload select-word-style
select-word-style shell
片段2:
setopt shwordsplit
我的问题是,它们有什么区别? (即他们做什么?)
另外,是否有按关键字索引zsh 文档? (例如,我无法轻松找到有关这两个片段的文档信息)。
如果这样的索引不存在,除了简单的 Google 搜索或在本网站上询问之外,是否有人对如何查找有关关键字(例如shwordsplit
或 )的文档有任何建议select-word-style
?
答案1
最好的方法是 zshall(1),它包含这两个以及所有 zsh 功能的文档,并且可以在您最喜欢的寻呼机中轻松搜索(少即是多):
$ man zshall
zsh -x -o shwordsplit scr
runs the script scr, setting the XTRACE option by the
corresponding letter `-x' and the SH_WORD_SPLIT option by name.
[…]
SH_WORD_SPLIT (-y) <K> <S>
Causes field splitting to be performed on unquoted parameter
expansions. Note that this option has nothing to do with word
splitting. (See the section `Parameter Expansion'.)
和
The simplest way of configuring the functions is to use
select-word-style, which can either be called as a normal
function with the appropriate argument, or invoked as a
user-defined widget that will prompt for the first character of
the word style to be used. The first time it is invoked, the
eight -match functions will automatically replace the builtin
versions, so they do not need to be loaded explicitly.