1
0
Fork 0
mirror of synced 2024-11-22 23:35:35 -05:00
zimfw/init.zsh

53 lines
1.3 KiB
Bash
Raw Normal View History

2015-12-15 00:12:17 -05:00
#
# 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
2015-12-15 00:12:17 -05:00
# Define zim location
(( ! ${+ZIM_HOME} )) && export ZIM_HOME="${ZDOTDIR:-${HOME}}/.zim"
2015-12-15 00:12:17 -05:00
# Source user configuration
2015-12-19 09:48:29 -05:00
if [[ -s "${ZDOTDIR:-${HOME}}/.zimrc" ]]; then
source "${ZDOTDIR:-${HOME}}/.zimrc"
2015-12-15 00:12:17 -05:00
fi
load_zim_module() {
local wanted_module
2015-12-19 09:48:29 -05:00
for wanted_module (${zmodules}); do
if [[ -s "${ZIM_HOME}/modules/${wanted_module}/init.zsh" ]]; then
source "${ZIM_HOME}/modules/${wanted_module}/init.zsh"
elif [[ ! -d "${ZIM_HOME}/modules/${wanted_module}" ]]; then
2015-12-19 09:48:29 -05:00
print "No such module \"${wanted_module}\"." >&2
2015-12-15 00:12:17 -05:00
fi
done
}
load_zim_function() {
local function_glob='^([_.]*|prompt_*_setup|README*)(-.N:t)'
local mod_function
# autoload searches fpath for function locations; add enabled module function paths
fpath=(${${zmodules}:+${ZIM_HOME}/modules/${^zmodules}/functions(/FN)} ${fpath})
2015-12-15 00:12:17 -05:00
function {
setopt LOCAL_OPTIONS EXTENDED_GLOB
for mod_function in ${ZIM_HOME}/modules/${^zmodules}/functions/${~function_glob}; do
2015-12-15 00:12:17 -05:00
autoload -Uz ${mod_function}
done
}
}
# initialize zim modules
load_zim_function
load_zim_module
2015-12-15 00:12:17 -05:00
unset zmodules
2015-12-29 01:28:18 -05:00
unfunction load_zim_{module,function}