Refactor tophist to work with zsh extended history