在 zsh 之外使用 zsh 补全

发布于 2024-09-16 04:30:42 字数 125 浏览 3 评论 0原文

在 zsh 之外使用 zsh 补全的最佳方法是什么?我知道我可以使用自定义函数重新定义 compadd 内置函数并解析其选项,但是有更好的方法吗?

我想基于 zsh 补全系统向 Vim 添加 shell 脚本的全能补全。

What is the best way to use zsh completion outside zsh? I know that I can redefine compadd builtin with custom function and parse its options, but is there a better way?

I want to add omni completion for shell scripts to Vim based on zsh completion system.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北城孤痞 2024-09-23 04:30:42

2004 年 8 月 23 日,zsh 邮件列表中也提出了同样的问题:http:// www.zsh.org/mla/users/2004/msg00917.html。至少我相信这是同一个问题。如果我错了请纠正我。

基本上,bash shell 使用 readline 进行行编辑,但 zsh 使用自己的、更强大的 zle

这个问题询问 zle 是否可以用于命令行程序的输入,而不必从头开始编写。

这个问题有2个回复。有人说:

“这实际上相对容易做到。有关工作示例,请参见
zsh 发行版中的 Functions/Misc/nslookup。”

另一个回复来自原始提问者,它说:

“如果只是‘preexec’可以访问 BUFFER,则编写编辑后的命令
该行可以写在任何地方,但由于 BUFFER 只能访问
在完成小部件内,这应该使用小部件完成,
替换“接受行”或类似的东西。”

希望这会有所帮助。

This same question was asked on the zsh mailing list on 23 Aug 2004: http://www.zsh.org/mla/users/2004/msg00917.html. At least I believe it's the same question. Correct me if I'm wrong.

Basically, the bash shell uses readline for its line-editing, but zsh uses its own and more powerful zle.

This question asks if zle can be used for input for a command line program instead of having to write it from scratch.

There are 2 replies to this question. One says:

"This is actually relatively easy to do. For a working example, see
Functions/Misc/nslookup in the zsh distribution."

The other reply is from the original asker and it says:

"If just 'preexec' could access BUFFER, writing the edited command
line could be written anywhere, but since BUFFER is only accessible
inside completion widgets, this should be done with a widget,
replacing 'accept-line' or something like that."

Hopefully this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文