1
0
Fork 0
mirror of synced 2024-11-12 19:18:57 -05:00
zimfw/init.zsh
Eric Nielsen 877fc06e72 [template] Use zrecompile and create digest file
for the autoloaded functions. According to the `zshbuiltins`
documentation:

    Files containing multiple compiled functions are called `digest'
    files,  and are intended to be used as elements of the FPATH/fpath
    special array.

Compile all module init files, instead of some selected ones.
This didn't impact performance much (time to run async block in zlogin
when from 0.22s to 0.25s on my machine).

Also refactor the zim `init.zsh` script, and do not unset `zmodules`
anymore because we need it in zlogin.

Didn't manage to make adding the prompt `prompt_*_setup` functions to
the digest file work, so kept these separate.

Fixes #86
2017-09-28 15:34:19 -05:00

41 lines
1.1 KiB
Bash
Executable file

#
# Zim initializition
#
autoload -Uz is-at-least
if ! is-at-least 5.2; then
print "ERROR: Zim didn't start. You're using zsh version ${ZSH_VERSION}, and versions < 5.2 are not supported. Update your zsh." >&2
return 1
fi
# Define zim location
(( ! ${+ZIM_HOME} )) && export ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
# Source user configuration
[[ -s ${ZDOTDIR:-${HOME}}/.zimrc ]] && source ${ZDOTDIR:-${HOME}}/.zimrc
# Autoload module functions
() {
local mod_function
setopt LOCAL_OPTIONS EXTENDED_GLOB
# autoload searches fpath for function locations; add enabled module function paths
fpath=(${ZIM_HOME}/functions.zwc ${ZIM_HOME}/modules/prompt/functions ${fpath})
for mod_function in ${ZIM_HOME}/modules/${^zmodules}/functions/^([_.]*|prompt_*_setup|README*)(-.N:t); do
autoload -Uz ${mod_function}
done
}
# Initialize modules
() {
local zmodule
for zmodule (${zmodules}); do
if [[ -s ${ZIM_HOME}/modules/${zmodule}/init.zsh ]]; then
source ${ZIM_HOME}/modules/${zmodule}/init.zsh
elif [[ ! -d ${ZIM_HOME}/modules/${zmodule} ]]; then
print "No such module \"${zmodule}\"." >&2
fi
done
}