Skip to content

Instantly share code, notes, and snippets.

@AaronH
Created January 8, 2010 23:45
Show Gist options
  • Save AaronH/272588 to your computer and use it in GitHub Desktop.
Save AaronH/272588 to your computer and use it in GitHub Desktop.
# View IRB History of this session
#
# irb_history # return all console commands this session
# irb_history 25 # return last 25 console commands from this session
# irb_history :all # return all console commands from all sessions
# irb_history :all, 25 # return last 25 console commands
#
def hist(*args)
limit = args.last.class == Fixnum ? args.last : MAXHISTSIZE
puts Readline::HISTORY.entries.split("exit").
send((args.first == :all ? 'flatten' : 'last'))[0..-2].
last(limit).join "\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment