当标准输入不是终端时,Ruby 提示(对于记事本明确)?
我是 Notepad++ 用户。 我喜欢该软件的功能之一是,您可以在 UI 中拥有一个“控制台”(不是实际的终端),并且可以从那里运行一些命令行解释器。
仅供参考,要在 Notepad++ 中运行控制台,您需要安装 NppExec 插件,然后转到 Menu >插件> NppExec>执行...
并输入您想要的任何可执行文件(exe、批处理等),然后按“确定”。将调出控制台,您将在其中看到程序的输出,如果是交互式 shell,您还可以输入命令。
例如,
- 对于实际的 DOS 提示符,您可以运行
cmd.exe
; - 对于 Python 提示符,您可以运行
python.exe -i
。- 来自 Python 帮助:
-i 运行脚本后交互式检查;即使 stdin 看起来不是终端也强制提示;还有 PYTHONINSPECT=x
- 来自 Python 帮助:
现在,我想知道是否有办法使用 irb 获得类似的提示。有人知道如何在 Notepad++ 中运行它吗?
更新
我得到的答案中提到它已经可以在 Notepad++ 5.4.5 中使用。在我看来,事实并非如此。
我从 Notepad++ 得到的内容:
我的期望:
I'm a Notepad++ user.
One of the features I like from that software is the fact that you can have a "console" in the UI (which is not an actual terminal), and that you can run some command line interpreters from there.
FYI, to get the console running in Notepad++, you need to have the NppExec plugin installed, and then go to Menu > Plugins > NppExec > Execute...
and type in whatever executable file you want in there (exe, batch, etc) and press OK. The Console will be brought up, and you'll see the output of your program in there, and in the case of an interactive shell, you can also input commands.
For example
- for an actual DOS prompt, you run
cmd.exe
- for a Python prompt, you run
python.exe -i
.- From the Python help:
-i inspect interactively after running script; forces a prompt even if stdin does not appear to be a terminal; also PYTHONINSPECT=x
- From the Python help:
Now, I'm wondering if there's a way to get a similar prompt with irb. Anybody has an idea how to get that running in Notepad++?
Update
There's mention in the answer(s) I got that it already works in Notepad++ 5.4.5. In my view, it does not.
What I get from Notepad++:
What I expect:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在npp_exec中使用以下脚本:
说明:要获取cmd的新实例,需要使用start命令。但启动命令只在cmd下有效。因此,您首先使用选项 /c 执行 cmd,这样它将执行后面的内容并在之后退出。
然后,您可以使用启动命令来执行您需要执行的内容。
为了使它更漂亮,你可以使用:
和以前一样,只是现在你使用 start 命令来启动带有选项 /q 的 cmd,它代表安静,与 .bat 文件中的 @echo off 作用相同。再次是 /c 选项。然后是你想要执行的事情加上之后的暂停。最后两件事在引号之间,因此第一次调用 cmd 不会在 npp_exec 控制台中执行它。
我有时使用这个脚本来执行java:
use the following script in npp_exec:
explanation: to get a new instance of cmd, you need to use the start command. But the start command only works in cmd. So you execute cmd first with option /c so it'll execute the stuff that follows and exit after that.
Then you use the start command with what you need to execute.
To make it a little prettier you can use:
same as before, only now you use the start command to start cmd with option /q, which stands for quiet and does the same as @echo off in a .bat file. Again the /c option. Then the thing you want to execute plus pausing afterwards. Those last two thing are between quotes so the first call to cmd doesn't execute it in the npp_exec console.
I use this script to execute java sometimes:
对于 IRB,只需运行 irb.bat。
这是它的样子(Notepad++ 5.4.5 和 NppExec 0.3 RC1):
alt text http //img198.imageshack.us/img198/8373/86448854.jpg
For IRB, just run irb.bat.
This is what it looks like (Notepad++ 5.4.5 and NppExec 0.3 RC1):
alt text http://img198.imageshack.us/img198/8373/86448854.jpg