如何将 bash 补全与程序捆绑在一起并使其在当前 shell 中运行?

发布于 2024-08-28 14:18:11 字数 118 浏览 3 评论 0原文

上面的问题我都捏了一把汗。我要提供的答案花了我一段时间才拼凑起来,但与重新设计完成以减少静态相比所能做的事情相比,它仍然显得无可救药地原始和老套。我几乎不敢问是否有一些充分的理由表明完成逻辑似乎完全脱离了它正在完成的程序。

I sweated over the question above. The answer I'm going to supply took me a while to piece together, but it still seems hopelessly primitive and hacky compared to what one could do were completion to be redesigned to be less staticky. I'm almost afraid to ask if there's some good reason that completion logic seems to be completely divorced from the program it's completing for.

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

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

发布评论

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

评论(1

习ぎ惯性依靠 2024-09-04 14:18:11

我写了一个命令行库(可以看到 在 scala trunk 中),它可以让你翻转开关以获得“--bash”选项。如果运行

./program --bash

它,它会计算完成文件,将其写入临时文件,然后回显

. /path/to/temp/file

到控制台。结果是您可以像这样使用反引号:

`./program --bash`

并且您将在当前 shell 中完成“program”,因为它将获取临时文件。

举个具体的例子:查看 scala trunk 并运行 test/partest。

I wrote a command line library (can be seen in scala trunk) which lets you flip a switch to have a "--bash" option. If you run

./program --bash

It calculates the completion file, writes it out to a tempfile, and echoes

. /path/to/temp/file

to the console. The result is that you can use backticks like so:

`./program --bash`

and you will have completion for "program" in the current shell since it will source the tempfile.

For a concrete example: check out scala trunk and run test/partest.

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