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:
    Ik0tWyI6ICJbIg0KIk0tXSI6ICJdIg0KIk0teyI6ICJ7Ig0KIk0tfSI6ICJ9Ig0KIk0tXCI6ICJcIg0KIk0tfCI6ICJ8Ig0KIk0tQCI6ICJAIg0KIk0tfiI6ICJ+IiA=
  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!

Related Posts:

  • No Related Posts
  • Ben St. John

    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

  • http://www.peterkrantz.com Peter Krantz

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

  • Daniel

    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!

  • http://dekstop.de/weblog/ Martin Dittus

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

    c2V0IEhPTUU9JUhPTUVQQVRIJQ==

    To create .inputrc:

    Y2QgJUhPTUVQQVRIJQ0KZWRpdCAuaW5wdXRyYw==

    Or do this:

    Y2QgJUhPTUVQQVRIJQ0KY29weSBjb24gLmlucHV0cmM=

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

  • http://eduardoflores.blogspot.com eduardo

    Spanish keyboard here… easyest workaround I’ve found:

    DQppcmIgLS1ub3JlYWRsaW5lDQo=
  • Michel

    –noreadline also works with French (AltGr)

  • http://www.ceng.metu.edu.tr/~e1347939/ tayfun

    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]

  • flip

    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

  • http://fredseltzer.com JFred

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

    DQpAc3RhcnQgInJhaWxzIGNvbnNvbGUiIC9NQVggcnVieSBzY3JpcHRcY29uc29sZQ0K

    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.

  • http://epirsch.blogspot.com/ Emmanuel Pirsch
  • rman

    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

  • Daniel

    rman, that worked like a charm. Thanks!

    Danish keyboard.