如何将 bash 补全与程序捆绑在一起并使其在当前 shell 中运行?
上面的问题我都捏了一把汗。我要提供的答案花了我一段时间才拼凑起来,但与重新设计完成以减少静态相比所能做的事情相比,它仍然显得无可救药地原始和老套。我几乎不敢问是否有一些充分的理由表明完成逻辑似乎完全脱离了它正在完成的程序。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我写了一个命令行库(可以看到 在 scala trunk 中),它可以让你翻转开关以获得“--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
It calculates the completion file, writes it out to a tempfile, and echoes
to the console. The result is that you can use backticks like so:
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.