From 73b44967111e7292f9e77cde1f9f3e3a744044a9 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sat, 10 Jun 2017 20:54:22 -0300 Subject: [PATCH] init.zsh: Allow arbitrary ZIM location This change allow arbitrary ZIM location path by setting a new environment variable, ZIM_PATH. If the user does not set it, ZIM falls back to the old "${ZDOTDIR:-${HOME}}/.zim" location. --- init.zsh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/init.zsh b/init.zsh index e5b1734..fd52a0e 100755 --- a/init.zsh +++ b/init.zsh @@ -3,7 +3,9 @@ # # Define zim location -ZIM="${ZDOTDIR:-${HOME}}/.zim" +if [[ -z "${ZIM_PATH}" ]]; then + ZIM_PATH="${ZDOTDIR:-${HOME}}/.zim" +fi # Source user configuration if [[ -s "${ZDOTDIR:-${HOME}}/.zimrc" ]]; then @@ -14,9 +16,9 @@ load_zim_module() { local wanted_module for wanted_module (${zmodules}); do - if [[ -s "${ZIM}/modules/${wanted_module}/init.zsh" ]]; then - source "${ZIM}/modules/${wanted_module}/init.zsh" - elif [[ ! -d "${ZIM}/modules/${wanted_module}" ]]; then + if [[ -s "${ZIM_PATH}/modules/${wanted_module}/init.zsh" ]]; then + source "${ZIM_PATH}/modules/${wanted_module}/init.zsh" + elif [[ ! -d "${ZIM_PATH}/modules/${wanted_module}" ]]; then print "No such module \"${wanted_module}\"." >&2 fi done @@ -27,12 +29,12 @@ load_zim_function() { local mod_function # autoload searches fpath for function locations; add enabled module function paths - fpath=(${${zmodules}:+${ZIM}/modules/${^zmodules}/functions(/FN)} ${fpath}) + fpath=(${${zmodules}:+${ZIM_PATH}/modules/${^zmodules}/functions(/FN)} ${fpath}) function { setopt LOCAL_OPTIONS EXTENDED_GLOB - for mod_function in ${ZIM}/modules/${^zmodules}/functions/${~function_glob}; do + for mod_function in ${ZIM_PATH}/modules/${^zmodules}/functions/${~function_glob}; do autoload -Uz ${mod_function} done }