I live in both Ruby and Python worlds and one of the features I really appreciate from iPython is autocomplete by up/down from any column of a input query to the console. That is, it can find all historical matches which match anything to the left of where I place the cursor.
For instance, with this as input, I'd like to hit the up key and get an auto-fill with the last similar command I ran:
irb(main):001:0> Order.where(<cursor> # up/down here to view similar history
Even better still would be if as I continue to hit the up key, I would then be able to continue cycling through similar commands, still based off the original cursor column at which I began. That is, I don't want to get one and then have the cursor at the end and find similar commands to.
If it helps, here's how I achieve that in bash for my profile, I'd just like to have this in a ruby/rails console too:
$ cat ~/.inputrc
# this makes the "delete" key work rather than
# just entering a ~
"\e[3~": delete-char
# these allow you to use ctrl+left/right arrow keys
# to jump the cursor over words
"\e[5C": forward-word
"\e[5D": backward-word
# these allow you to start typing a command and
# use the up/down arrow to auto complete from
# commands in your history
"\e[B": history-search-forward
"\e[A": history-search-backward
# this lets you hit tab to auto-complete a file or
# directory name ignoring case
set completion-ignore-case On
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[2~": quoted-insert
I currently have this in my ~/.irbrc
, but that doesn't quite accomplish autocompletion of sub-commands for column position greater than zero.
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 200
IRB.conf[:HISTORY_FILE] = "/home/me/.irb-history"
Is there already a way to do this already in Rails/Ruby or is there a way to achieve this in a rails/ruby console? I've already read Can I get the Ruby on Rails console to remember my command history, umm, better? and How to view the entire Rails console history?, but they don't achieve the level of precision I'm looking for here.
Thanks!