zsh补全资源?
Zsh 补全是一个相当复杂的野兽,我发现手册页非常难以阅读,尤其是它缺少所有各种 optspec 形式等的(简单)示例。我自己还没有在网上找到任何内容,所以帮助是最受赞赏。
作为一个例子,这是我目前正在努力解决的问题,并且 zshcompsys 手册页没有提供任何说明。现在
#compdef mtt2
_arguments -s : \
'-h' '--help' \
'-V' '--version' \
':foobars:(foo bar baz)'
,当我输入 mtt2
时,我只提供 foo
、bar
和 baz
作为补全,为什么不使用 -h
、--help
等呢? 我需要向 _arguments
传递什么魔力才能获得所有可能性?
Zsh completion is a rather complex beast, and I find the man-page very difficult to read, especially it's missing (simple) examples of all the various optspec forms etc. I haven't managed to find anything online myself yet so help would be most appreciated.
As an example here's what I'm struggling with at the moment, and the zshcompsys
man-page doesn't offer any clarifications. I have
#compdef mtt2
_arguments -s : \
'-h' '--help' \
'-V' '--version' \
':foobars:(foo bar baz)'
Now, when I type mtt2 <TAB>
I'm only offered foo
, bar
and baz
as completions, why not -h
, --help
, etc, as well?
What magic do I need to pass to _arguments
in order to be offered all possibilities?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要开始用破折号完成的参数(我的意思是您输入要测试的参数,而不是
_arguments
参数)。您应该查看zstyle
,尝试传递-h
和其他类似:foobars:
的内容,甚至直接使用compadd.示例:
-h
和其他内容,就像:foobars:
一样:zstyle
控制完成样式。它在man zshcompsys
的“完成系统配置”部分中进行了描述,并且可能有一个可以完成开关的选项,但我不知道哪个选项可以控制它。You need to start argument that you complete with dash (I mean that argument that you type to test, not
_arguments
argument). You should either look atzstyle
, try to pass-h
and others just like:foobars:
or even directly usecompadd
. Examples:-h
and others just like:foobars:
:or
zstyle
controls completion style. It is described in «COMPLETION SYSTEM CONFIGURATION» section inman zshcompsys
and probably has an option that will enable completing of switches, but I do not know which option controls that.