summaryrefslogtreecommitdiff
path: root/oh-my-zsh.sh
diff options
context:
space:
mode:
authorMarc Cornellà <marc.cornella@live.com>2020-05-04 16:51:16 +0200
committerGitHub <noreply@github.com>2020-05-04 16:51:16 +0200
commitdd1a72696f162fd5285a104b5f63970deb66e8b0 (patch)
tree6c9a59354c5f5512f77fc09e56228bd70ac88b09 /oh-my-zsh.sh
parent173d4ca68f1ff4b04e9f3fd783244c309d848092 (diff)
downloadzsh-dd1a72696f162fd5285a104b5f63970deb66e8b0.tar.gz
zsh-dd1a72696f162fd5285a104b5f63970deb66e8b0.tar.bz2
zsh-dd1a72696f162fd5285a104b5f63970deb66e8b0.zip
core: refresh zcompdump cache file in init script (#8878)
Diffstat (limited to 'oh-my-zsh.sh')
-rw-r--r--oh-my-zsh.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index 30259372c..092099325 100644
--- a/oh-my-zsh.sh
+++ b/oh-my-zsh.sh
@@ -61,6 +61,18 @@ if [ -z "$ZSH_COMPDUMP" ]; then
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
fi
+# Construct zcompdump OMZ metadata
+zcompdump_metadata="\
+#omz revision: $(cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)
+#omz fpath: $fpath\
+"
+
+# Delete the zcompdump file if OMZ zcompdump metadata changed
+if ! cmp -s <(command grep '^#omz' "$ZSH_COMPDUMP" 2>/dev/null) <<< "$zcompdump_metadata"; then
+ command rm -f "$ZSH_COMPDUMP"
+ zcompdump_refresh=1
+fi
+
if [[ $ZSH_DISABLE_COMPFIX != true ]]; then
source $ZSH/lib/compfix.zsh
# If completion insecurities exist, warn the user
@@ -72,6 +84,13 @@ else
compinit -u -C -d "${ZSH_COMPDUMP}"
fi
+# Append zcompdump metadata if missing
+if (( $zcompdump_refresh )); then
+ echo "\n$zcompdump_metadata" >>! "$ZSH_COMPDUMP"
+fi
+
+unset zcompdump_metadata zcompdump_refresh
+
# Load all of the config files in ~/oh-my-zsh that end in .zsh
# TIP: Add files you don't want in git to .gitignore