You can do this easily with zsh’s standard features. I love having years of my command history! It's all combined across sessions and instantly searchable with the standard ^R.
These are most of the settings in ZSH I use to enable all that.
HISTSIZE=10000000
SAVEHIST=10000000
setopt EXTENDED_HISTORY # logs the start and elapsed time
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FIND_NO_DUPS
Apple now even recommends zsh shell over bash! =)
https://support.apple.com/en-us/HT208050 (it's the 10.15 default)