From: Trans Date: 2008-10-21T01:31:36+09:00 Subject: Re: Best Command Prompt On Oct 20, 9:33 am, Jens Wille wrote: > hi trans! > > Trans [2008-10-20 15:23]:> I've been using wirble which improves irb a bit (although I hate that > > it doesn't allow duplicate entries in the history --anyone know how to > > fix?). > > i always hated that it would store history entries in oldest-first > order. so i just copied the code for save_history from wirble.rb > into my .irbrc and adjusted it accordingly: > >   require 'wirble' > >   # save history newest-first, instead of default oldest-first >   class Wirble::History >     def save_history >       return unless Object.const_defined? :IRB > >       path, max_size, perms = %w{path size perms}.map { |v| cfg(v) } > >       # read lines from history, and truncate the list (if necessary) >       #lines = Readline::HISTORY.to_a.uniq >       lines = Readline::HISTORY.to_a.reverse.uniq.reverse >       lines = lines[-max_size..-1] if lines.size > max_size > >       # write the history file >       real_path = File.expand_path(path) >       File.open(real_path, perms) { |fh| fh.puts lines } >       say 'Saved %d lines to history file %s.' % [lines.size, path] >     end >   end > > you could simply change the line that fills the 'lines' array to > something like this: > >       lines = Readline::HISTORY.to_a > awesome. thanks jens. maybe i'll do a little work on wirble to make it more flexible for variant preferences like ours and post a patch. t.