匹配器列表参数在 zsh zstyle 补全中如何工作?
我正在尝试配置我的 ~/.zshrc 以便文件/目录上的代码完成可以根据需要工作。 我在网上找到了有关 zstyle 完成语法和代码示例的各种资源,但其中的某些部分对我来说仍然是黑魔法。
到目前为止,经过一些摆弄和测试后,这就是我所在的位置:
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'm: {a-zA-Z}={A-Za-z} l:|=* r:|=*'
以下是我从中了解到的内容:
zstyle ':completion:*'
表示我们将定义一个完成的配置值matcher-list
是我们更新的配置,这里它定义了 zsh 如何匹配文件/目录来建议'm:{a-zA-Z}={A-Za-z}' 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'< /code> 是参数(值)传递到
matcher-list
配置。- 这里我有两个参数,用空格分隔。这意味着 zsh 将首先尝试查找与第一个参数匹配的文件,如果没有找到任何文件,则会尝试与第二个参数匹配的文件
这里它变得模糊:
- 我明白了
'm:{a-zA-Z} ={A-Za-z}'
使匹配大小写不敏感,但我不太理解语法。 - 我还发现
'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'
仍然不区分大小写,但也搜索匹配整个字符串,而不仅仅是开头。但是,我也不明白语法。
有人可以证实我之前的断言,并在需要时更正它们,并详细说明参数的巫毒语法吗?
谢谢
编辑:哦,抱歉,如果这个问题更适合 superuser.com,我很难确定哪个网站更适合它。
I'm trying to configure my ~/.zshrc so code completion on files/dirs work as I need it.
I've found various ressources online on the zstyle completion syntax, and code example but some parts of it are still black magic to me.
So far, here is where I am, after some fiddling and testing :
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'
Here is what I understand from it :
zstyle ':completion:*'
means we are going to define a config value for completionmatcher-list
is the config we update, here it defines how zsh match files/dir to suggest'm:{a-zA-Z}={A-Za-z}' 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'
are the arguments (values) to pass to thematcher-list
config.- Here I have two arguments, separated by a space. It means zsh will first try to find files that match the first arg, and if it found nothing will try files that match the second arg
And here it becomes fuzzy :
- I get that
'm:{a-zA-Z}={A-Za-z}'
make the match case insensitive but I do not quite understand the syntax. - I also get that
'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'
still is case insensitive, but also search for the match in the whole string, not just the start. But, I don't get the syntax either.
Can someone confirm my previous assertions, and correct them if needed, as well as detail the voodoo syntax of the arguments ?
Thanks
Edit : Oh, and sorry if the question is more fitted to superuser.com, I had a hard figuring which site was better suited for it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您好,zsh 文档位于
http://zsh .sourceforge.net/Doc/Release/Completion-Widgets.html#Completion-Matching-Control
Hi the zsh doc for this is at
http://zsh.sourceforge.net/Doc/Release/Completion-Widgets.html#Completion-Matching-Control