Non ho una risposta per voi perché quanto sopra non funziona, ma ho trovato un file, /etc/irbrc
sul mio sistema (OS X - Snow Leopard, Ruby 1.8.7) che fornisce un funzionamento, storia persistente per me. Quindi due consigli: i) controlla il tuo/etc/irbrc (o equivalente) per assicurarti che non ci sia nulla che possa interferire con le tue impostazioni, e ii) prova le impostazioni seguenti per vedere se riesci ad ottenere la storia funziona in quel modo.
# Some default enhancements/settings for IRB, based on
# http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks
unless defined? ETC_IRBRC_LOADED
# Require RubyGems by default.
require 'rubygems'
# Activate auto-completion.
require 'irb/completion'
# Use the simple prompt if possible.
IRB.conf[:PROMPT_MODE] = :SIMPLE if IRB.conf[:PROMPT_MODE] == :DEFAULT
# Setup permanent history.
HISTFILE = "~/.irb_history"
MAXHISTSIZE = 100
begin
histfile = File::expand_path(HISTFILE)
if File::exists?(histfile)
lines = IO::readlines(histfile).collect { |line| line.chomp }
puts "Read #{lines.nitems} saved history commands from '#{histfile}'." if $VERBOSE
Readline::HISTORY.push(*lines)
else
puts "History file '#{histfile}' was empty or non-existant." if $VERBOSE
end
Kernel::at_exit do
lines = Readline::HISTORY.to_a.reverse.uniq.reverse
lines = lines[-MAXHISTSIZE, MAXHISTSIZE] if lines.nitems > MAXHISTSIZE
puts "Saving #{lines.length} history lines to '#{histfile}'." if $VERBOSE
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
ETC_IRBRC_LOADED=true
end
Che piattaforma stai usando? Sono abbastanza sicuro che l'installazione predefinita di OS X non ha il supporto di readline integrato a causa di problemi di licenza. –
Quello che hai sembra funzionare per me su doze, tranne che devo colpire due frecce in alto per qualche motivo. – rogerdpack
Questa soluzione ha funzionato per me: http://stackoverflow.com/questions/1752461/history-not-saving –