Using Ruby's Readline Library

ruby

Tue Jan 22 20:48:00 -0800 2008

There appears to be no documentation for Ruby’s readline support. What’s worse, it’s written in C, so you can’t (easily) read the source to find out its interface.

By peering at IRB’s source, however, I was able to construct the following:

require 'readline'

loop do
  line = Readline::readline('> ')
  Readline::HISTORY.push(line)
  puts "You typed: #{line}"
end