如何使irb和rails控制台在gitbash中正常工作? [英] How to get irb and rails console to work properly in gitbash?

查看:88
本文介绍了如何使irb和rails控制台在gitbash中正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 7上使用gitbash版本2.9.0(64位),它使用的是薄荷版本2.0.3.

I'm using gitbash ver 2.9.0, 64-bit, on Windows 7. It uses mintty version 2.0.3.

大多数时候gitbash shell似乎运行良好.您可以像使用任何bash shell一样使用箭头键等,它们会按预期运行,可以滚动浏览先前的命令等.

The gitbash shell most of the time seems to work fine. You can use the arrow keys, etc, as with any bash shell and they perform as expected, being able to scroll through prior commands, etc.

但是,当使用irbrails console(运行irb)时,它非常易碎.向上箭头不是滚动浏览先前的命令,而是将光标向上移动到屏幕上方,然后将可能是向上箭头的控制代码输入到输入缓冲区中.另外,irb必须以^ C而不是^ D退出. ^ D除了进入输入缓冲区外什么都不做(如果我输入^ D然后^ C,由于^ C会退出irb,然后由于^ D会退出gitbash).

However, when using irb or rails console (which runs irb) it is very flakey. Rather than scroll through prior commands, the up arrow just moves the cursor up the screen and enters what are probably up arrow control codes into the input buffer. In addition, irb must be exited with ^C rather than ^D. The ^D does nothing except go into the input buffer (if I type ^D then ^C, it exits irb because of the ^C, then exits gitbash because of the ^D).

在这个问题上,我找不到其他报告的方式,发现的东西有些陈旧.我已经尝试了本文中显示的解决方案:

I can't find much in the way of other reports on this issue and what little I've found is somewhat old. I've tried the solutions shown in this post: Backspace and arrow keys aren't working in IRB (Git Bash console) on windows machine, but they haven't changed the behavior at all.

有人找到解决这个问题的合法方法吗?

Has anyone found a legitimate solution to this problem?

推荐答案

git bash终端仿真器(mintty)与Windows控制台程序实际上并不兼容.因此,您可能需要查找运行控制台程序(例如,irb.cmd包装器 >等),然后与git bash交互.

The git bash terminal emulator (mintty) does not really get along with windows console programs. So you might want to look for a wrapper that runs a console program (e.g. irb.cmd, python.exe, etc) then interfaces with the git bash.

具体来说,一旦git bash的$PATH中包含wintpy.exeirb,就可以设置别名

Concretely, once you have wintpy.exe and irb in your $PATH of the git bash, you can set an alias as such

$ alias irb='winpty "$(which irb).cmd"'

请注意,默认的ruby Windows安装程序附带了两个irb:一个很好的旧bash脚本irb和一个Windows批处理脚本irb.cmd. winpty技巧只有后者对我有用.

NOTE that there are two irbs shipped with the default ruby windows installer: a good old bash script irb and a windows batch script irb.cmd. Only the latter works for me with the winpty trick.

这篇关于如何使irb和rails控制台在gitbash中正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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