Change Location of zcompdump Files
Asked Answered
N

2

11

Is it possible to change the location of .zcompdump and .zhistory files generated by ZSH?
They are polluting my Home Directory.
One possible solution I found was changing the value of $ZDOTDIR to $HOME/.config/zsh. I did the following, but it does not seem to work (temp files are still created in the home directory).

$ cat ~/.zshenv
ZDOTDIR=$HOME/.zsh
. $ZDOTDIR/.zshenv
Needless answered 11/12, 2017 at 1:7 Comment(2)
I found that setting export ZDOTDIR=/your/path/here in the global configs works (for me, that's located at /etc/zsh/zshenv).Private
@Private that works, but if you use ZSH as default shell you gotta put .zshrc at $ZDOTDIR.Pug
S
25

.zcompdump files are produced to speed up the running of compinit, Which initializes the shell completion in zsh. You could specify an explicit dump file by compinit -d <dumpfile> in your .zshrc to change the location where compdump are stored.

Change the value for HISTFILE to set different location to store you zsh command history.

Spanner answered 2/1, 2018 at 8:16 Comment(1)
I was able to get this to work by changing $ZDOTDIR. Thanks anyways :)Needless
K
2
$ man zshall
/Use of compinit

 To speed up the running of compinit, it can be made to produce a dumped 
configuration that will be read in on future invocations; this is the 
default, but can be turned off by calling compinit with the option -D.  The 
dumped file is .zcompdump in the same directory as the startup files (i.e. 
$ZDOTDIR or $HOME); alternatively, an explicit file name can be given by 
`compinit -d dumpfile'.  The next invocation of compinit will read the 
dumped file instead of performing a full initialization.
Koblas answered 12/8, 2022 at 7:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.