This functionality is included in some ruby gems (Utility Belt seems to be the most popular), but I'm more of a "roll-your-own" kinda guy. Not to mention that the gem is a little overkill for printing out command history.
Here's what I came up with: