This repository has been archived on 2020-09-21. You can view files and clone it, but cannot push or open issues or pull requests.
zim/templates/zlogin
Matt Hamilton ef8e4bd3be remove zcompare's return
No need to make returns for tests that we aren't making success/failure
checks for; the function itself deals with what needs to be zcompiled.
2015-12-31 11:09:08 -05:00

59 lines
1.9 KiB
Bash

#
# startup file read in interactive login shells
#
# The following code helps us by optimizing the existing framework.
# This includes zcompile, zcompdump, etc.
#
(
# Function to determine the need of a zcompile. If the .zwc file
# does not exist, or the base file is newer, we need to compile.
# These jobs are asynchronous, and will not impact the interactive shell
zcompare() {
if [[ -s ${1} && ( ! -s ${1}.zwc || ${1} -nt ${1}.zwc) ]]; then
zcompile ${1}
fi
}
# First, we will zcompile the completion cache, if it exists. Siginificant speedup.
zcompare ${ZDOTDIR:-${HOME}}/.zcompdump
# Next, zcompile .zshrc if needed
zcompare ${ZDOTDIR:-${HOME}}/.zshrc
# Now, zcompile some light module init scripts
zcompare ${ZDOTDIR:-${HOME}}/.zim/modules/git/init.zsh
zcompare ${ZDOTDIR:-${HOME}}/.zim/modules/utility/init.zsh
zcompare ${ZDOTDIR:-${HOME}}/.zim/modules/pacman/init.zsh
zcompare ${ZDOTDIR:-${HOME}}/.zim/modules/spectrum/init.zsh
zcompare ${ZDOTDIR:-${HOME}}/.zim/modules/completion/init.zsh
zcompare ${ZDOTDIR:-${HOME}}/.zim/modules/custom/init.zsh
# Then, we should zcompile the 'heavy' modules where possible.
# This includes syntax-highlighting and completion.
# Other modules may be added to this list at a later date.
zim=${ZDOTDIR:-${HOME}}/.zim
setopt EXTENDED_GLOB
#
# syntax-highlighting zcompile
#
if [[ -d ${zim}/modules/syntax-highlighting/external/highlighters ]]; then
# compile the highlighters
for file in ${zim}/modules/syntax-highlighting/external/highlighters/**/*.zsh; do
zcompare ${file}
done
# compile the main file
zcompare ${zim}/modules/syntax-highlighting/external/zsh-syntax-highlighting.zsh
fi
#
# zsh-histery-substring-search zcompile
#
if [[ -s ${zim}/modules/history-substring-search/external/zsh-history-substring-search.zsh ]]; then
zcompare ${zim}/modules/history-substring-search/external/zsh-history-substring-search.zsh
fi
) &!