From 871b15663cbb8d6b13efc9ba734c6ee2781c7e07 Mon Sep 17 00:00:00 2001 From: Kaleb Elwert Date: Tue, 2 May 2017 01:36:23 -0700 Subject: [PATCH] Cache the completion for a quicker startup The original idea was by @samjonester in #1210. This version aims to avoid relying on the stat or date programs because they have different flags depending on the OS and if it uses BSD or GNU coreutils. --- modules/completion/init.zsh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/completion/init.zsh b/modules/completion/init.zsh index 620a9b3..912c586 100644 --- a/modules/completion/init.zsh +++ b/modules/completion/init.zsh @@ -14,9 +14,6 @@ fi # Add zsh-completions to $fpath. fpath=("${0:h}/external/src" $fpath) -# Load and initialize the completion system ignoring insecure directories. -autoload -Uz compinit && compinit -i - # # Options # @@ -27,9 +24,21 @@ setopt PATH_DIRS # Perform path search even on command names with slas setopt AUTO_MENU # Show completion menu on a successive tab press. setopt AUTO_LIST # Automatically list choices on ambiguous completion. setopt AUTO_PARAM_SLASH # If completed parameter is a directory, add a trailing slash. +setopt EXTENDED_GLOB # Needed for file modification glob modifiers with compinit unsetopt MENU_COMPLETE # Do not autoselect the first completion entry. unsetopt FLOW_CONTROL # Disable start/stop characters in shell editor. +# Load and initialize the completion system ignoring insecure directories with a +# cache time of 20 hours, so it should almost always regenerate the first time a +# shell is opened each day. +autoload -Uz compinit +compfiles=(${ZDOTDIR:-$HOME}/.zcompdump(Nm-20)) +if [[ $#compfiles > 0 ]]; then + compinit -i -C +else + compinit -i +fi + # # Styles #