def history(num=100)
h = Readline::HISTORY.to_a
start = [0,h.size-num-1].max
h.zip((0..h.size).to_a)[start...h.size].each do |cmd,i|
puts " #{(i).to_s.rjust(4)} #{cmd}"
end
end
I keep it in my .irbrc file, really useful to avoid stepping through command history to find previous commands.