IRB doesn't respect dot (.) as a word-break character
Asked Answered
B

2

9

I'm using irb on OS X, and when I press option left/right (or META+B/F) the cursor moves to the next/previous word. But irb doesn't wont to treat dot (.) character as a word separator.

I've tried to add the (.) to the .irbrc, so it looks like this now:

Readline.basic_word_break_characters = " \t\n`><=.;|&{("

But that has no effect.

I'm using the stock Mountain Lion ruby, and a manually compiled 1.9.3, both versions of irb behave similar. Also dot is treated as a separator in bash and in pry, so the system wide settings are probably fine.

Any help appreciated,

Thanks

Borlase answered 10/10, 2012 at 15:26 Comment(1)
similar question: https://mcmap.net/q/1318452/-word-boundaries-in-irbInfantile
B
5

Ok, it seems that the problem was that there were no libreadline installed in my system at all. Installing the latest readline and recompiling ruby fixed the problem.

I've used readline 6.2 from ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz, which was installed used the basic ./configure && make && make install.

And I've installed ruby 1.9.3-p194 using ruby-build with the following options

sudo ruby-build 1.9.3-p194 /opt/ruby-1.9.3-p194 CONFIGURE_OPTS="--with-readline-dir=/usr/local"

After that IRB started treating dots, underscores and a bunch of other characters as word separators.

Also the properly working readline should return something like:

Readline::VERSION => "6.2"     

and the misbehaving one says:

Readline::VERSION => "EditLine wrapper"
Borlase answered 11/10, 2012 at 13:1 Comment(1)
thanks, this worked for me. Combined with some information from (https://mcmap.net/q/815787/-make-error-installing-ruby-1-9-2-with-rvm-and-readline-under-osx-lion) I was able to get this working under rvm as well.Noisette
M
1

If you're having trouble with the above (either it failed to install or you just need more instruction), here's what I did to make it work.

For those on latest Mac OS X (10.11.2 El Capitan):

curl ftp://ftp.cwru.edu/pub/bash/readline-6.3.tar.gz > temp-readline.tar.gz then unzip with tar temp-readline.tar.gz. Then go into that directory with cd readline-6.3. Configure and install with ./configure && make && make install, just like above.

Hope this helps.

Meras answered 23/1, 2016 at 7:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.