Skip to content

Instantly share code, notes, and snippets.

@vizv
Forked from ctechols/compinit.zsh
Created April 29, 2022 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vizv/dd21ad8e9c99d0ad57653ded05c77297 to your computer and use it in GitHub Desktop.
Save vizv/dd21ad8e9c99d0ad57653ded05c77297 to your computer and use it in GitHub Desktop.
Speed up zsh compinit by only checking cache once a day.
# 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 -Uz compinit
if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then
compinit;
else
compinit -C;
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment