运行 IRB 命令历史记录中的最后 X 个命令?
我正在一个屏幕中使用 Vim 开发一个 ruby 应用程序,而在另一个屏幕中我使用 irb 来测试我在 Vim 中编写的代码。
在这个例子中,我们假设只有 2 个 irb 命令来测试我编写的代码,一个加载和一个方法调用。
一般来说,它超过 2 个命令 - 如果只有 2 个命令,我会点击向上箭头两次并按 Enter 键,但通常大约有 5 或 6 个命令,最多需要按 36 个按键才能运行最后 6 个命令。 一定有一种更简单的方法。
有没有一种简单的方法可以按照执行顺序从 irb readline 历史缓冲区执行最后 X 个命令,其中 X 是您要运行的命令数?像这样的东西;
run_last_x_commands(i)
我很确定这将是一段自定义编写的代码,我只是想知道是否有人已经解决了这个问题,或者这是否是我需要自己编写的东西。
I'm developing a ruby app with Vim in one screen, and in another I'm using irb to test the code I'm writing in Vim.
For the sake of this example, we'll say there are only 2 irb commands to test the code that I've written, a load and a method call.
Generally, it's more than 2 commands - if its just 2 I would tap the up arrow twice and hit enter, but generally its around 5 or 6 and that's up to 36 key presses just to run the last 6 commands. There must be an easier way.
Is there an easy way to execute the last X commands from the irb readline history buffer in the order they were executed, where X is the number of commands you want to run? Something like;
run_last_x_commands(i)
I'm pretty sure it would be a custom written piece of code, I'm just wondering if anyone already solved this problem or if this is something I'll need to write myself.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能有兴趣在 IRB 中运行 Vim。
宝石。
来源。
You may be interested in running Vim in IRB.
Gem.
Source.
我真的会把你的测试脚本存储在一个文件中。它不像直接输入那样方便,但同时也更容易编辑和使用。另外,如果您尝试定义类,您经常会遇到 IRB 无法重新定义类而不执行诸如 Object.remove_const('MyClass') 之类的操作的问题。我遇到了与您相同的问题,并且我决定不使用 IRB 来完成此任务。
不过,可能有一些 readline 魔法可以做你想做的事。 Readline 有各种我不知道的技巧和捷径。
I would really store your test script in a file. It is less convenient than just typing it out, but at the same time, it's easier to edit and work with. Plus, if you're trying to define classes, you often get issues with IRB not able to redefine a class without doing things like Object.remove_const('MyClass'). I've had the same problem you're having, and I decided against using IRB for this task.
There may be some readline magic to do what you want though. Readline has all kinds of tricks and shortcuts I don't know about.