I understand that command line history in the case of bash is saved in .bash_history
.
When you open a terminal emulator window in Ubuntu/MacOS and work in it, the history is not saved in .bash_history
yet but when you close the window, the history of the session will be appended to the end of the .bash_history
file.
My question is: where are the history saved during the session, before I close the emulator window?
The reason I care is that sometimes I mess up wile working in it and the terminal window simply freeze. When I force close it, I lose all the history contained in the session. I want to be able to retrieve them.
PROMPT_COMMAND
in bash on MacOS? I guess they may be already callinghistory -a
from it, in which case the OP can retrieve the history of recently crashed sessions fromls -t ~/.bash_sessions/ | head
?