upvote
This is exactly why I stopped using Bash around 2012. I was soooo tired of losing random shell history.

If you haven't looked into ZSH, it has some really nice customizations. Notably, from my config[1]:

  # Remove dups
  setopt HIST_FIND_NO_DUPS
  setopt HIST_IGNORE_DUPS
  # Don't  log commands starting with a space
  setopt HIST_IGNORE_SPACE
  # Replcae bang-command !34 with the actual command in the history
  setopt BANG_HIST
  # Remove extraneous spaces
  setopt HIST_REDUCE_BLANKS
  # Write the history file in the ":start:elapsed;command" format
  setopt EXTENDED_HISTORY
  # Record run-time of the command
  setopt INC_APPEND_HISTORY_TIME
[1] https://doc.xn0.org/.zshrc
reply
Running bash inside zsh continuously destroyed my history for the last 3 years until I figured that HISTFILE was exported and inherited by bash.
reply
That's what zsh's INC_APPEND_HISTORY (mentioned in TFA) avoids. Bash may have an equivalent.
reply