I'm trying to change the default location of the zsh completion cache files in macOS. I have read the zsh documentation on completion which say's "alternatively, an explicit file name can be given by ‘compinit -d dumpfile’" I set the ZCOMPCACHE variable and proceeded with the following code:
ZCOMPCACHE="$HOME/.cache/zsh/zcompcache"
# Create the parent directory if it doesn't exist
[[ -d $ZCOMPCACHE ]] || mkdir -p $ZCOMPCACHE
# Set the custom location for zcompdump files
_comp_files=($HOME/.cache/zsh/zcompcache(Nm-20))
if (( $#_comp_files )); then
compinit -i -C -d "$HOME/.cache/zsh/zcompcache/.zcompdump-${ZSH_VERSION}"
else
compinit -i -d "$HOME/.cache/zsh/zcompcache/.zcompdump-${ZSH_VERSION}"
fi
# `unset` the temporary variable
unset _comp_files
The code works and creates the zcompcache directory under .cache/zsh and dumps the cache file to that location.
However, I'm still getting a .zcompdump file dumped in my $HOME directory even though I've set a specific location.
I used to use oh-my-zsh but I found it too bloated for my requirements, could there be any residual settings left over from the previous oh-my-zsh configuration that may be causing the additional .zcompdump in my $HOME directory?