Something erased my bash history!

An AI image depicting the time when my bash history was gone.

So I noticed that some stuff was missing from .bash_history . It is not a total loss. I just noticed that some sessions were missing. I have been through a bunch of the settings and can't figure it out. Here are the relevant settings from my .bashrc:

# history
shopt -s cmdhist
shopt -s histappend
shopt -s histverify

export HISTFILE=~/.bash_history
export HISTSIZE=65536
export HISTFILESIZE=65536
# export HISTTIMEFORMAT="%y-%m-%d,%T "
export HISTCONTROL="erasedups:ignoreboth"
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history"

I am going to save every command myself. I added this to my .bashrc file:

# Something is erasing my bash history, sidestep the issue:
log_command() {
    status=$?
    current_datetime=$(date '+%Y-%m-%d,%H:%M:%S')
    terminal_device=$(tty)
    shell_pid=$$
    user_login=$(whoami)

    terminal_session_info="$terminal_device $shell_pid $user_login"

    # Append the information to a log file
    echo "; # STATUS=$status" >> ~/.bash_historical
    echo -n "$current_datetime $terminal_session_info $BASH_COMMAND" >> ~/.bash_historical
 }

trap 'log_command' DEBUG

Anyway, the output seems parseable:

2025-06-28,18:43:29 /dev/pts/1 92841 user free -h; # STATUS=0
2025-06-28,18:43:34 /dev/pts/1 92841 user pwd; # STATUS=0
2025-06-28,18:43:49 /dev/pts/1 92841 user df -h; # STATUS=0
2025-06-28,18:43:56 /dev/pts/1 92841 user exit

I should be able to separate separate shells and subshells by using the time/dev/pid combo. I should be able to parse this with awk or perl or python or lua, but you know that I am only going to use grep.

So, yeah, I did this and it changed my life.

Comments:

🛹 @steve2792 3 minutes ago.
GET CASH FOR INTERNET POINTS AT SCAMAPP.SCAM

🛵 @lacey7963 7 minutes ago.
Why are you even using bash?

🌵 @simon2224 13 minutes ago.
How dare you!

💾 @oliver9736 18 minutes ago.
Actually, if you recompile bash from source with the appropriate changes, you can fix this.

🎧 @HughHacker 23 minutes ago.
It's not HISTIGNORE.

🛵 @lacey7963 27 minutes ago.
HISTIGNORE, duh.