From: ghorner Date: 2009-07-24T03:50:06+09:00 Subject: thoughts on rewriting irb? Hi, I wrote up a post on a mini irb which does better irb completion, persistent history and error handling in 7 lines: http://tagaholic.me/2009/07/23/mini-irb-and-mini-script-console.html If you're curious the code looks like this: %w{readline rubygems bond bond/completion}.each {|e| require e } history_file = File.join(ENV["HOME"], '.mini_irb_history') IO.readlines(history_file).each {|e| Readline::HISTORY << e.chomp } if File.exists?(history_file) while (input = Readline.readline('>> ', true)) != 'exit' begin puts "=> #{eval(input).inspect}"; rescue Exception; puts "Error: #{$!}" end end File.open(history_file, 'w') {|f| f.write Readline::HISTORY.to_a.join ("\n") } Since that probably came out horribly, you could also just see this snippet: http://gist.github.com/68608 At first, it may seem like a joke to compare it to irb but imho it does the brunt of what a repl should do. All of irb's features: workspaces, jobs, config options, command framework are features which the majority of ruby programmers don't seem to use. Personally the only thing I'd port to mini-irb is a ruby lexer to detect multiple lines of ruby. So what are other people's two cents? If you could rewrite irb, what features would you give it?