Starting in OS X 10.11 El Capitan, the system-installed script
/etc/bashrc_Apple_Terminal coordinates with Terminal in order to save/restore separate command histories for each terminal restored for Resume.
Read the comments in
/etc/bashrc_Apple_Terminal for an explanation of how it manages per-terminal command histories and how to customize it.
If you customize
PROMPT_COMMAND be sure to concatenate to the previous value so you don't wipe out the system-supplied command:
If you install an
EXIT signal handler with
trap be sure to do something similar (or call shell_session_update from your handler if you can't figure out how to concatenate to the previous value—it's a little involved).
When you exit the shell, this code will save new commands to the terminal's history in
~/.bash_sessions. To see if it encounters any problems, instead of closing the terminal exit the shell manually with
exit (or Control-D). It logs progress messages. Note if it doesn't complete or if any sort of warning or error messages are displayed.
bashrc_Apple_Terminal attempts to detect and disable per-session history if it looks like the user has performed any customizations that aren't compatible with it. It sounds like you may have found one it doesn't handle. Please consider filing a bug report with Apple: https://developer.apple.com/bug-reporting/