Reputation: 58224
I'm using gitbash ver 2.9.0, 64-bit, on Windows 7. It uses mintty version 2.0.3.
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.
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?
Upvotes: 4
Views: 3203
Reputation: 1
In addition to krim's answer, you can put
alias irb='winpty "$(which irb).cmd"'
alias rails='winpty "$(which rails).bat"'
in a text file and save it as .bashrc in your home directory %homepath%
. Then you won't have to type it in the console every time you start up git bash.
Source: Comment on https://fool-dev.com/switch-to-inspect-mode-on-gitbash-in-windows/
Upvotes: 0
Reputation: 117
Many Thanks to krim!
After learning the add-.cmd
-trick, I tried the same for rails console bin/rails c
) and ended with a ~/scripts/rails_
bash script:
#!/usr/bin/bash
winpty rails.bat "$@"
So I can do now rails_ c
or rails_ db
etc.
Upvotes: 0
Reputation: 148
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.
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"'
NOTE that there are two irb
s 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.
Upvotes: 5