How to make irb and rails console work properly in gitbash?

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

In most cases, the gitbash shell works fine. You can use the arrow keys, etc., As with any bash shell, and they perform, as expected, the ability to scroll through previous commands, etc.

However, when using irbor rails console(which works irb) it is very opaque. Instead of scrolling through previous commands, the up arrow moves the cursor up the screen and enters what probably contains the arrow control codes into the input buffer. Also, it irbshould be output using ^ C, not ^ D. ^ D does nothing except enter the input buffer (if I type ^ D, then ^ C, it exits because irbof ^ C, and then exits from gitbash due to ^ D).

I cannot find much on the way to other posts on this subject, and what I found is somewhat outdated. I tried the solutions shown in this post: Backspace and arrow keys do not work in IRB (Git bash console) on a Windows computer , but they did not change the behavior at all.

Has anyone found a legal solution to this problem?

+4
source share
2 answers

The git bash ( mintty) terminal emulator does not cope with Windows console programs. Therefore, you may want to find a wrapper that runs the console program (eg irb.cmd, python.exeetc.), then interacts with the git bash.

Specifically, if you have wintpy.exeand irbin $PATHgit bash, you can set an alias as such

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

Note that there are two irbthat come with the default ruby ​​window installer: the good old bash script irband the Windows script package irb.cmd. Only the latter works for me with a trick winpty.

+1

krim! add- .cmd -trick, rails bin/rails c) ~/scripts/rails_ bash script:

#!/usr/bin/bash
winpty rails.bat "$@"

rails_ c rails_ db ..

0

All Articles