This is a very good blog post by Martin Heinz on how to configure zsh to take better advantage of your shell history.

At the end he mentions atuin, for syncing your shell history across multiple devices with end-to-end encryption. I’ve been using it for a while and the shell history search is also quite nice.