в ~/.irbrc у меня есть эти строки:
require 'irb/ext/save-history'
#History configuration
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
и все же когда я работаю irb
и поражает стрелка вверх, ничего не происходит. также irb определенный файл истории не становится созданным, и ничто не зарегистрировано к нему.
У меня нет ответа для вас, почему вышеуказанное не работает, но я нашел файл / etc / irbrc
в моей системе (OS X - Snow Leopard, Ruby 1.8. 7) Это обеспечивает работу, постоянную историю для меня. Таким образом, два совета: i) проверьте ваш / etc / irbrc (или эквивалент), чтобы убедиться, что там нет ничего, что может вмешиваться в ваши настройки, и ii) попробуйте настройки ниже, чтобы увидеть, если вы можете получить История работает таким образом.
# 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
История IRB работает в Debian Linux из коробки. Нет etc / irbrc, и у меня нет ~ / .irbrc. Итак, хмммм.
Этот человек положил немного больше в его IRBRC, чем вы. Вы думаете, argv.concat может быть недостающим произведением?
require 'irb/completion'
require 'irb/ext/save-history'
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
Это известная ошибка с патчем. Самое простое решение - перезаписать save-history.rb:
/usr/lib/ruby/1.8/irb/ext/save-history.rb
с исправленной версией:
или сделать это за один заход:
wget -O /usr/lib/ruby/1.8/irb/ext/save-history.rb http://pastie.org/pastes/513500/download