On several occasions, I have lost some of my bash history, as the ssh session has not been exited cleanly. This annoyed me as I use the history as a means to remember what I have done. It prompted me to investigate if I could fix it and Unix being Unix, of course you can.
The History part of my
.bashrc file now looks like this;
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
# append to the history file, don't overwrite it
shopt -s histappend
# BPO force all commands to be saved on one line
shopt -s cmdhist
# BPO append the command to the history after every command
# prevents lost history when exit is not used
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
# BPO Save a time stamp
# HISTTIMEFORMAT='%F %T '
# BPO Don't save common commands
I tried adding a timestamp but that just looked messy so I took it out again.