-
-
Save 15cm/88e320d71fe7fe5a4bb24b99da6b93f0 to your computer and use it in GitHub Desktop.
Speed up zsh compinit by only checking cache once a day.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# compinit optimization for oh-my-zsh | |
# On slow systems, checking the cached .zcompdump file to see if it must be | |
# regenerated adds a noticable delay to zsh startup. This little hack restricts | |
# it to once a day. It should be pasted into your own completion file. | |
# | |
# The globbing is a little complicated here: | |
# - '#q' is an explicit glob qualifier that makes globbing work within zsh's [[ ]] construct. | |
# - 'N' makes the glob pattern evaluate to nothing when it doesn't match (rather than throw a globbing error) | |
# - '.' matches "regular files" | |
# - 'mh+24' matches files (or directories or whatever) that are older than 24 hours. | |
#autoload -U compaudit compinit | |
#: ${ZSH_DISABLE_COMPFIX:=true} | |
# ... | |
setopt extendedglob | |
if [[ $ZSH_DISABLE_COMPFIX != true ]]; then | |
# If completion insecurities exist, warn the user without enabling completions. | |
if ! compaudit &>/dev/null; then | |
# This function resides in the "lib/compfix.zsh" script sourced above. | |
handle_completion_insecurities | |
# Else, enable and cache completions to the desired file. | |
else | |
if [[ -n "${ZSH_COMPDUMP}"(#qN.mh+24) ]]; then | |
compinit -d "${ZSH_COMPDUMP}" | |
compdump | |
else | |
compinit -C | |
fi | |
fi | |
else | |
if [[ -n "${ZSH_COMPDUMP}"(#qN.mh+24) ]]; then | |
compinit -i -d "${ZSH_COMPDUMP}" | |
compdump | |
else | |
compinit -C | |
fi | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment