in Rails, Ruby

Setting up the Interactive Ruby Shell (IRB) for non-english keyboards on Windows XP

For some reason it is difficult to use the [] and {} characters when using IRB with a non-english keyboard on Windows XP. To get it working together with tab completion:

  1. Create a new environment variable called “HOME” and set it to your user home folder (e.g. C:\Documents and Settings\peterk).
  2. Create a text dcument called “.inputrc” in your user home folder with the following content:
    "M-[": "["
    "M-]": "]"
    "M-{": "{"
    "M-}": "}"
    "M-\": "\"
    "M-|": "|"
    "M-@": "@"
    "M-~": "~" 
  3. Make sure irb.bat is using the –readline option (irb.bat is located in the bin folder of your ruby installation).

That’s it!


  1. For me, invoking irb with the –noreadline made things work without requiring the .inputrc file (which windows explorer doesn’t like as a name).

    (perhaps setting the INPUTRC environment variable to point the file (whatever it’s name) would also do the trick.


  2. I guess you are supposed to use newlines in the .inputrc content. At least that was how I got it to work. Thanks anyway for pointing out the direction!

  3. –noreadline works well for me up to the point where you want to exit irb — ^C, ^D, ^Z have no effect. So thanks for this .inputrc workaround.

    To quickly set up the HOME env variable you can also simply put this in your irb.bat:


    To create .inputrc:

    cd %HOMEPATH%
    edit .inputrc

    Or do this:

    cd %HOMEPATH%
    copy con .inputrc

    … then paste Peter’s .inputrc content above (with a right mouse click), make sure you end the input with a blank line, hit ^Z and enter.

    10 years time to forget all about DOS, and it just came back in a rush… ;)

  4. Hello,
    Thanks for the solution but I find that this does not work for the Turkish keyboard. Can you direct me on how a solution can be found for the Turkish keyboard case? Another .inputrc for example?

    [–noreadline works but I want tab completion too]

  5. doesn’t work for me :(

    checked everything twice:
    1. set home-path to a path with .inputrc
    2. the .inputrc in the home-path has the above lines and a free line at the end (tried different encodings (dos/unix/utf8))
    3. in console.rb i modified the irc-call to
    exec “#{options[:irb]} #{libs} –simple-prompt –readline”

    if i now start the console, still no special chars like [] are possible. running with –noreadline works well, but i really miss the console functions like to browse with the arrow keys through the console history.

    any idea?



  6. As long as you’re talking Windows XP. Start it this way. Put this into console.cmd:

    @start "rails console" /MAX ruby script\console

    Then just run ‘console’ from the command line, and it will start up in its own window.

    I found that using the –noreadline option makes it work better. Otherwise history gets confused after you enter a long line. Tab completion is less important than history, for me.

  7. You can manipulate the init.rb file (located in $ruby_installtion\lib\ruby\versionxxx\irb)

    Scroll down and set the following line to:
    @CONF[:USE_READLINE] = false

    (comment the following stuff on the same line: #unless defined?(ReadlineInputMethod))
    Hope this helps

  8. rman, that worked like a charm. Thanks!

    Danish keyboard.

Comments are closed.