[zsh] improve compdump handling when initializing the completion system

This commit is contained in:
Dmytro Meleshko 2019-08-26 22:42:07 +03:00
parent c55c9af578
commit 1f97d82654

View file

@ -4,10 +4,33 @@ source "$ZSH_DOTFILES/zplg.zsh"
plugin completions 'zsh-users/zsh-completions' plugin completions 'zsh-users/zsh-completions'
# Oh-My-Zsh {{{ run_compinit() {
autoload -U compinit
# initialize the completion system local match run_compdump=1
autoload -Uz compinit && compinit -C # glob qualifiers description:
# N turn on NULL_GLOB for this expansion
# . match only plain files
# m-1 check if the file was modified today
# see "Filename Generation" in zshexpn(1)
for match in $HOME/.zcompdump(N.m-1); do
run_compdump=
break
done
if [[ -n "$run_compdump" ]]; then
# -D flag turns off compdump loading
compinit -D
compdump
else
# -C flag disables some checks performed by compinit - they are not needed
# because we already have a fresh compdump
compinit -C
fi
}
run_compinit
# Oh-My-Zsh {{{
ZSH_CACHE_DIR="$ZSH_DOTFILES/cache" ZSH_CACHE_DIR="$ZSH_DOTFILES/cache"