Sha256: 1bafed885fa4f3d9f6852bfc29d8551a7a72aacd6732e955665d3942d88e1461
Contents?: true
Size: 884 Bytes
Versions: 45
Compression:
Stored size: 884 Bytes
Contents
# with thanks to @liwp ( http://blog.lauripesonen.com/ ) at http://stackoverflow.com/questions/2065923/irb-history-not-working module Nydp module ReadlineHistory HISTFILE = "~/.nydp_history" MAXHISTSIZE = 100 def setup_readline_history verbose=true histfile = File::expand_path(HISTFILE) begin if File::exists?(histfile) lines = IO::readlines(histfile).collect { |line| line.chomp } Readline::HISTORY.push(*lines) end Kernel::at_exit do lines = Readline::HISTORY.to_a.reverse.uniq.reverse lines = lines[-MAXHISTSIZE, MAXHISTSIZE] if lines.size > MAXHISTSIZE File::open(histfile, File::WRONLY|File::CREAT|File::TRUNC) { |io| io.puts lines.join("\n") } end rescue => e puts "Error when configuring permanent history: #{e}" if verbose end end end end
Version data entries
45 entries across 45 versions & 1 rubygems