Add history-stats function to show most used commands.

Takes two optional arguments. Usage example:

> history-stats 2000 50

Showing most used 50 commands in past 2000 history entries.
...