2015-12-15 00:12:17 -05:00
|
|
|
#
|
|
|
|
# Zim initializition
|
|
|
|
#
|
|
|
|
|
2017-06-28 17:55:48 -04:00
|
|
|
autoload -Uz is-at-least
|
|
|
|
if ! is-at-least 5.2; then
|
2017-07-30 19:24:58 -04:00
|
|
|
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
|
2017-06-28 17:55:48 -04:00
|
|
|
fi
|
|
|
|
|
2015-12-15 00:12:17 -05:00
|
|
|
# Define zim location
|
2017-09-26 13:28:08 -04:00
|
|
|
(( ! ${+ZIM_HOME} )) && export ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
|
2015-12-15 00:12:17 -05:00
|
|
|
|
|
|
|
# Source user configuration
|
2017-09-26 13:28:08 -04:00
|
|
|
[[ -s ${ZDOTDIR:-${HOME}}/.zimrc ]] && source ${ZDOTDIR:-${HOME}}/.zimrc
|
2015-12-15 00:12:17 -05:00
|
|
|
|
2017-09-26 13:28:08 -04:00
|
|
|
# Autoload module functions
|
|
|
|
() {
|
2015-12-15 00:12:17 -05:00
|
|
|
local mod_function
|
2017-09-26 13:28:08 -04:00
|
|
|
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
2015-12-15 00:12:17 -05:00
|
|
|
|
|
|
|
# autoload searches fpath for function locations; add enabled module function paths
|
2018-01-03 10:16:45 -05:00
|
|
|
fpath=(${ZIM_HOME}/modules/${^zmodules}/functions(/FN) ${fpath})
|
2015-12-15 00:12:17 -05:00
|
|
|
|
2018-01-02 20:30:45 -05:00
|
|
|
for mod_function in ${ZIM_HOME}/modules/${^zmodules}/functions/^([_.]*|prompt_*_setup|README*|*.zwc|*.zwc.old)(-.N:t); do
|
2017-09-26 13:28:08 -04:00
|
|
|
autoload -Uz ${mod_function}
|
|
|
|
done
|
2015-12-15 00:12:17 -05:00
|
|
|
}
|
|
|
|
|
2017-09-26 13:28:08 -04:00
|
|
|
# Initialize modules
|
|
|
|
() {
|
|
|
|
local zmodule
|
2015-12-15 00:12:17 -05:00
|
|
|
|
2017-09-26 13:28:08 -04:00
|
|
|
for zmodule (${zmodules}); do
|
|
|
|
if [[ -s ${ZIM_HOME}/modules/${zmodule}/init.zsh ]]; then
|
|
|
|
source ${ZIM_HOME}/modules/${zmodule}/init.zsh
|
2018-03-29 13:14:06 -04:00
|
|
|
elif [[ -s ${ZIM_HOME}/modules/${zmodule}/${zmodule}.plugin.zsh ]]; then
|
|
|
|
source ${ZIM_HOME}/modules/${zmodule}/${zmodule}.plugin.zsh
|
2018-03-29 00:40:24 -04:00
|
|
|
elif [[ -s ${ZIM_HOME}/modules/${zmodule}/${zmodule}.zsh ]]; then
|
2018-03-29 12:09:08 -04:00
|
|
|
source ${ZIM_HOME}/modules/${zmodule}/${zmodule}.zsh
|
2018-03-29 13:14:06 -04:00
|
|
|
elif [[ -s ${ZIM_HOME}/modules/${zmodule}/zsh-${zmodule}.plugin.zsh ]]; then
|
|
|
|
source ${ZIM_HOME}/modules/${zmodule}/zsh-${zmodule}.plugin.zsh
|
|
|
|
elif [[ -s ${ZIM_HOME}/modules/${zmodule}/zsh-${zmodule}.zsh ]]; then
|
|
|
|
source ${ZIM_HOME}/modules/${zmodule}/zsh-${zmodule}.zsh
|
2017-09-26 13:28:08 -04:00
|
|
|
elif [[ ! -d ${ZIM_HOME}/modules/${zmodule} ]]; then
|
|
|
|
print "No such module \"${zmodule}\"." >&2
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
2017-10-23 10:33:57 -04:00
|
|
|
|
|
|
|
zmanage() {
|
|
|
|
local usage="zmanage [action]
|
|
|
|
Actions:
|
|
|
|
update Fetch and merge upstream zim commits if possible
|
|
|
|
info Print zim and system info
|
|
|
|
issue Create a template for reporting an issue
|
|
|
|
clean-cache Clean the zim cache
|
|
|
|
build-cache Rebuild the zim cache
|
|
|
|
remove *experimental* Remove zim as best we can
|
|
|
|
reset Reset zim to the latest commit
|
|
|
|
debug Invoke the trace-zim script which produces logs
|
|
|
|
help Print this usage message"
|
|
|
|
|
|
|
|
if (( ${#} != 1 )); then
|
|
|
|
print ${usage}
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
case ${1} in
|
|
|
|
update) zsh ${ZIM_HOME}/tools/zim_update
|
|
|
|
;;
|
|
|
|
info) zsh ${ZIM_HOME}/tools/zim_info
|
|
|
|
;;
|
|
|
|
issue) zsh ${ZIM_HOME}/tools/zim_issue
|
|
|
|
;;
|
|
|
|
clean-cache) source ${ZIM_HOME}/tools/zim_clean_cache && print 'Cache cleaned'
|
|
|
|
;;
|
|
|
|
build-cache) source ${ZIM_HOME}/tools/zim_build_cache && print 'Cache rebuilt'
|
|
|
|
;;
|
|
|
|
remove) zsh ${ZIM_HOME}/tools/zim_remove
|
|
|
|
;;
|
|
|
|
reset) zsh ${ZIM_HOME}/tools/zim_reset
|
|
|
|
;;
|
|
|
|
debug) zsh ${ZIM_HOME}/modules/debug/functions/trace-zim
|
|
|
|
;;
|
|
|
|
*) print ${usage}; return 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|