Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

.zsh_history



I don’t have anything special set up other than setting HISTFILE, HISTSIZE=2097152, and SAVEHIST=1048576.  I also have histignoredups and histignorealldups on.

The reason for the huge numbers is partially due to some confusion I had (see below) but basically I want to save unique commands that I did for very long periods of time so I don’t need to figure them out again.

I’m on macOS and they have this thing for “sessions” which I’ve turned off now (a few weeks ago).  The reason is that the session history files are limited to two weeks and so commands I did long ago are getting deleted and my .zsh_history file was only growing to be about 1000 lines.

My question is, if I start multiple terminals and run various commands and eventually they each log out or exit, I’m wondering what happens to the .zsh_history file.  Does the last shell to exit rewrite the file using its own history which (I’m guessing) is the contents of .zsh_history when the shell started up plus the commands that were executed in that shell?  This would overwrite all the commands done in the other shells that have just exited.

Alternatively, the shell could re-read .zsh_history at the time it is exiting and append the commands that were executed within that shell and write the result out — thus preserving the commands done by other shells.  I see in the /etc/zsh_Apple_Terminal file some dancing around that appears to be trying to re-read the history file at the time the shell is exiting.  I haven’t looked closely at what precisely it is doing.  I thought I would ask first what is the default behavior.

TL; DR: question: Does zsh re-read the .zsh_history file at the time it is exiting by default?

Thank you,
Perry

Attachment: signature.asc
Description: Message signed with OpenPGP



Messages sorted by: Reverse Date, Date, Thread, Author