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!

Comments

  1. Ben St. John says at 2006-01-12 17:01:

    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.

    Ben

  2. Peter Krantz says at 2006-01-12 19:01:

    Ben, that would make special characters work, but tab-completion fail.

  3. Daniel says at 2006-01-12 21:01:

    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!

  4. Martin Dittus says at 2006-03-25 17:03:

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

    set HOME=%HOMEPATH%

    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… ;)

  5. eduardo says at 2006-06-29 15:06:

    Spanish keyboard here… easyest workaround I’ve found:

    
    irb --noreadline
    

  6. Michel says at 2006-07-15 15:07:

    –noreadline also works with French (AltGr)

  7. tayfun says at 2006-09-28 18:09:

    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]

  8. flip says at 2007-07-17 00:07:

    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?

    thanks!

    cheers,
    flip

  9. JFred says at 2007-12-12 16:12:

    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.

  10. Emmanuel Pirsch says at 2008-02-12 18:02:

    This solution did not work for me, but changing the “M-” with “\e” in the .inputrc file solved the problem for good.

  11. rman says at 2008-04-29 09:04:

    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

  12. Daniel says at 2008-07-21 15:07:

    rman, that worked like a charm. Thanks!

    Danish keyboard.

Leave a comment

You can use some HTML elements. You know which they are.