Add command to trim the history database.

With this, `ipython history trim` will cut the history database back to the last 1000 entries, with an optional backup (`--backup`).

I wrote this while investigating startup performance. I *think* trimming the history gives a small improvement, probably <10%, in cold start time, but there's quite a lot of noise in the timings.