I just write all my commands to a log. It's saved me a number of times.
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)Worth reading why they did that: https://thenextweb.com/dd/2019/06/04/why-does-macos-catalina...
I do this from Emacs (you can use Helm or Ivy, for example) and it's extremely convenient and effective to quickly get old commands back.