Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ruby

irb

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

like image 898
Dmitry Sokurenko Avatar asked Oct 10 '12 15:10

Dmitry Sokurenko


2 Answers

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"
like image 177
Dmitry Sokurenko Avatar answered Nov 11 '22 01:11

Dmitry Sokurenko


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.

like image 30
Geoff Lee Avatar answered Nov 11 '22 00:11

Geoff Lee