1

I symlink dot files from my home directory to actual files in a separate folder that is under git source control. This works great, but for some reason I am having problems with .zhistory.

$ echo $HISTFILE
/Users/amelio/.zhistory
$ cd & ln -s $DOT_FILES_REPO/.zhistory .
$ fc -W && fc -R

After running the above, I see that .zhistory is not a symlink after the last command. Why? And how can I have .zhistory live in my home directory with a symlink to a different file?

1 Answer 1

3

When zsh updates the history file, it creates a temporary file, then moves it into place, the equivalent of

print the history >.zhistory.new
mv .zhistory.new .zhistory

If .zhistory was a symbolic link before, it isn't one afterwards.

The advantage of this method is that if zsh crashes (because of a bug, because it's killed abruptly, because of a sudden reboot) then the history file is untouched. In particular, the history file is never left truncated or invalid.

If you want to put your history file in a different location, don't use a symbolic link, set the HISTFILE variable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .