Something very strange happened with the Mac OS X Mojave terminal, when I logout or type exit or command + d, the following message appears:
Saving session ...
... copying shared history ...
... saving history ... truncating history files ...
Apparently everything is OK, but when I go back to the terminal I see that I lost all the history, it was not recorded. I made cat in .bash_history and the file is empty.
I searched on several sites, but found no solution, because nobody knows what happened.
Then I decided to analyze the files in the home directory as below:
0 drwxr-xr-x + 21 aperture staff 672B Sep 27 21:06.
0 drwxr-xr-x 6 root admin 192B Sep 26 16:53 ..
8 -r -------- 1 amptec staff 7B Sep 27 12:58 .CFUserTextEncoding
24-rw-r-r - @ 1 opening staff 10K Sep 27 20:46 .DS_Store
0 drwx ------ 10 amptec staff 320B Sep 27 20:46 .Trash
0 drwxr-xr-x 14 amptec staff 448B Sep 26 17:48 .atom
8 -rw ------- 1 amptec staff 1.1K Sep 27 20:41 .bash_history
0 drwx ------ 29 amptec staff 928B Sep 27 23:07 .bash_sessions
0 drwx ------ 3 amptec staff 96B Sep 27 20:38 .ssh
. . . . .
I noticed that there is a .bash_sessions directory and I've listed its contents:
$ ls .bash_sessions /
I made cat in these session file and saw that the executed commands were written to these files, but they were not transferred to .bash_history.
I closed all the terminal windows and closed the terminal with command + q, opened the terminal again and continued with the empty history.
Removed the session files with the following command:
rm -rf .bash_sessions / *
I closed the terminal again.
I reloaded the terminal and did some new tests and everything worked to normal.