Ruby在stdin不是终端时提示(明确地用于Notepad ++)? [英] Ruby prompt when stdin isn't a terminal (for Notepad++ explicitely)?

查看:71
本文介绍了Ruby在stdin不是终端时提示(明确地用于Notepad ++)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Notepad ++用户。
我喜欢该软件的功能之一是您可以在UI中拥有一个控制台(这不是实际的终端),并且可以从那里运行一些命令行解释器。

仅供参考,要使控制台在Notepad ++中运行,您需要安装NppExec插件,然后转到 Menu>插件> NppExec>执行... 并在其中键入所需的任何可执行文件(exe,批处理等),然后按OK。将打开控制台,您将在其中看到程序的输出,对于交互式外壳,还可以输入命令。



例如,对于实际的DOS提示符,




  • 运行 cmd.exe

  • 对于Python提示符,运行 python.exe -i


    • 从Python帮助中: -i在运行脚本后进行交互式检查;即使stdin似乎不是终端,也强制进行提示;也PYTHONINSPECT = x




现在,我我想知道是否有办法用irb得到类似的提示。有人知道如何在Notepad ++中运行它吗?



更新



我得到的答案中提到它已经在Notepad ++ 5.4.5中起作用。在我看来,它不是。



我从Notepad ++获得的信息:



alt文字http://content.screencast.com/users/JocelynLegault/folders/Jing/media/7cec643e-0924-479d-b31a-a40c691ec25d/2009-11-18_1814.png



我期望什么:



替代文本http://content.screencast.com/users/JocelynLegault/folders/ Jing / media / 211d1b9f-6f66-458e-9a19-61b7e9b19b43 / 2009-11-18_1816.png

解决方案

在npp_exec中使用以下脚本:

  cmd / c start what_you_want_to_execute 

说明:获取新实例o f cmd,您需要使用启动命令。但是start命令仅在cmd中有效。因此,您首先使用选项/ c执行cmd,这样它将执行后面的内容,然后退出。
然后在需要执行的内容上使用start命令。



要使其更漂亮,可以使用:

  cmd / c start cmd / q / c what_you_want_to_execute&&&暂停 

与以前相同,只是现在您使用start命令以/ q选项启动cmd,该选项代表安静,在.bat文件中的作用与@echo off相同。还是/ c选项。然后,您要执行的事情加上事后暂停。最后两件事在引号之间,因此对cmd的首次调用不会在npp_exec控制台中执行。



我有时使用此脚本执行Java:

  cmd / c开始cmd / q / c C:\Progra〜1\Java\jdk1.6.0_17\bin\java.exe -classpath $(CURRENT_DIRECTORY) $(NAME_PART)&&暂停 


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

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++:

alt text http://content.screencast.com/users/JocelynLegault/folders/Jing/media/7cec643e-0924-479d-b31a-a40c691ec25d/2009-11-18_1814.png

What I expect:

alt text http://content.screencast.com/users/JocelynLegault/folders/Jing/media/211d1b9f-6f66-458e-9a19-61b7e9b19b43/2009-11-18_1816.png

解决方案

use the following script in npp_exec:

cmd /c start what_you_want_to_execute

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:

cmd /c start cmd /q /c "what_you_want_to_execute && pause"

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:

cmd /c start cmd /q /c "C:\Progra~1\Java\jdk1.6.0_17\bin\java.exe -classpath "$(CURRENT_DIRECTORY)" "$(NAME_PART)" && pause"

这篇关于Ruby在stdin不是终端时提示(明确地用于Notepad ++)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆