If your arrow-keys print an escape sequence in IRB, it could be due to the Ruby Readline module when used with
Readline.vi-editing-mode and Readline 6.2.
Consequently, although I prefer vi mode, I've disabled it for now to work around the IRB inconvenience.
Ruby 1.9.3p392. In
Ruby 2.0.0p0 IRB, arrow-keys misbehave slightly differently.
1.9.3p392 :001 > a = 1 => 1 1.9.3p392 :003 > [A # Up arrow pressed here, # line should be "a = 1".
Check if vi editing mode is enabled:
1.9.3p392 :003 > Readline.vi_editing_mode? => true
In my case, it was set due to my
set editing-mode vi
Check if Ruby's readline.bundle is compiled against Readline 6.2:
ldd readline.so # Linux otool -L readline.bundle # MacOS
Note on MacOS, the Readline module could be compiled against libedit, which is a replacement for libreadline. However, AFAIK, it does not implement vi edit mode. In that case, you might need to change
$HOME/.editrc. Google and StackOverflow will help you here.