You might also want to add one improvement:
Write commands to history files before running the commands instead of after the commands finish:
trap 'history -a' DEBUG
Or if you already have a DEBUG trap: trap "history -a ; $(trap -p DEBUG | cut -d "'" -f 2)" DEBUG
For the curious, the salient .bashrc bits are:
EDIT: Remembered just after submitting that since I am on MacOS, I ran the command back on August 22nd, 2020, to prevent Terminal from saving per-session information. I've never cleaned out ~/.bash_sessions, suppose I should, but it hasn't been updated since that day.