A thing to do with your environment setup, so a tool I suppose? There are probably different plugins out there for it. In my case it's a few lines in .bashrc that override the history processing to never delete old history, and add tags indicating which session wrote the command. This way I can reboot a computer, restart all 30 screen sessions, and have each access backward searchable history to the start of time (2013 for me).
I'm guessing newer shells may have better support for this kind of thing instead of running shell commands to wrangle text files on every prompt.