hist: configurable path and cleaner purge.

The history file path can now be configured by setting the env var HISTORY.

The purge operation filters duplicates before droping the history n-tail.