Sample Header Ad - 728x90

Why do I lose my ZSH history?

47 votes
7 answers
23204 views
Every once in a while I discover my zsh history has been truncated (or maybe lost entirely, difficult to tell), and I have to restore it from backup. For example, today:
ls -lh ~/.zsh_history
-rw-------  1 stripe  staff    32K 21 Feb 10:20 /Users/stripe/.zsh_history
But in my backup from a few days ago:
-rw-------@  1 stripe  staff  203K 17 Feb 22:36 /Volumes/Time Machine Backups/.../Users/stripe/.zsh_history
I have configured zsh to save lots of history so it shouldn't be a matter of the shell intentionally trimming the file.
unsetopt share_history
setopt inc_append_history
setopt hist_ignore_all_dups
HISTSIZE=500000
SAVEHIST=$HISTSIZE
Has anyone else experienced this and found a way to mitigate it? Is there some zsh spring cleaning feature I'm unaware of?
Asked by Alexander Ljungberg (639 rep)
Feb 21, 2020, 10:34 AM
Last activity: Apr 17, 2025, 06:51 AM