在unix shell中获得REPL的便利有什么途径? (或反之亦然)
我使用很多命令通过子命令提供某种 API。例如,
git push
bzr push
apt-get install
过了一段时间,我厌倦了写git推送,git提交,git一些东西......因为我知道唯一的事情我现在使用的“提交”、“推送”等都是 git。
在使用过提供 REPL 的语言(Ruby、Python 等)之后,我失去了打字的便利性。
$ git pus... ## arrgh!
$ from git import *
$ push ## yes!
我发现 git 之类的命令与预见的编程语言中的命名空间或模块之间存在明显的对称性。
那么,问题是:如何才能在 SHELL 中支持命名空间?反之亦然,如何才能让这些语言取代 SHELL?
I use a lot of commands providing exposing a sort of API via subcommands. For instance,
git push
bzr push
apt-get install
After a while, I get tired of writing git push, git commit, git something... because I know the only thing I'm using to 'commit', 'push', etc. is git at this moment.
Having played with languages providing a REPL (Ruby, Python, etc.) I was missing the convenience of typing.
$ git pus... ## arrgh!
$ from git import *
$ push ## yes!
I see a clear symmetry between commands like git and namespaces or modules in the forementined programming languages.
So, the question is: what does it take to have support for namespaces in SHELL? or vice-versa, What does it take to have these language replace the SHELL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,这很难做到。但是,您可以近似类似的东西...
使用命令名称调用,例如
现在,当您说例如
install foo
时,您实际上会执行apt-get install foo
。其他改进(例如更智能的选项卡完成)是可能的,但肯定需要特定于命令的代码。
This would be extremely hard to do generically. However, you can approximate something similar...
Invoke with the name of the command, e.g.
And now when you say e.g.
install foo
you will actually executeapt-get install foo
.Additional improvements, such as more intelligent tab completion, are possible but would certainly require command-specific code.