I have multiple files of `.zcompdump` , why do I have multiple files of these?
Asked Answered
P

3

54

I have multiple files of .zcompdump*.

.rw-r--r--   47k myuser 13 Jul 10:02  .zcompdump
.rw-r--r--   47k myuser 14 Jul 16:52  .zcompdump-MacBook Pro (2)-5.7.1
.rw-r--r--   47k myuser  4 Jun  9:32  .zcompdump-MacBook Pro-5.7.1
.rw-r--r--   36k myuser  3 Jul 11:07  .zcompdump.macbook-pro-2.lan.54221

Which one of them do zsh actually use? Can i clear out some of them or?

Prepositor answered 16/7, 2020 at 8:57 Comment(0)
W
31

Because the compinit mechanism of zsh creates the filename depending on some environment variable, here $HOST.

It's safe to delete them, but they will be recreated unless you add -D to compinit line in your zsh config

https://github.com/wurmlab/oswitch/issues/41

They are used to speed up the completion mechanism.
You can delete them and let it recreate the one you need.

Weatherproof answered 17/7, 2020 at 9:45 Comment(0)
M
65

I added this line to the ~/.zshrc above the source $ZSH/oh-my-zsh.sh line:

export ZSH_COMPDUMP=$ZSH/cache/.zcompdump-$HOST

Then, when we source $ZSH/oh-my-zsh.sh, the compinit command dumps to that new location.

Here's where compinit is in oh-my-zsh.sh.

Markle answered 25/2, 2022 at 21:9 Comment(2)
Bless you. So sick of programs dumping caches, histories etc. to $HOME - it's not acceptable behaviour for any programMaretz
There is an old PR to do something similar here. Hopefully it will get approved and merged.Accordant
W
31

Because the compinit mechanism of zsh creates the filename depending on some environment variable, here $HOST.

It's safe to delete them, but they will be recreated unless you add -D to compinit line in your zsh config

https://github.com/wurmlab/oswitch/issues/41

They are used to speed up the completion mechanism.
You can delete them and let it recreate the one you need.

Weatherproof answered 17/7, 2020 at 9:45 Comment(0)
A
4

I figured someone would need this, based on "the Tin Man" answer:

sed -i -e "/source \$ZSH\/oh-my-zsh.sh/i export ZSH_COMPDUMP=\$ZSH\/cache\/.zcompdump-\$HOST" ~/.zshrc

It saves you the time of opening a file to find a specific line.

Amadavat answered 16/7, 2020 at 8:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.