From 7346efd206015609c64537310cf6e45bb392bc72 Mon Sep 17 00:00:00 2001 From: Kaleb Elwert Date: Tue, 7 Mar 2017 17:42:41 -0800 Subject: [PATCH] Allow setting ZPREZTODIR to make prezto easier to integrate with --- init.zsh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/init.zsh b/init.zsh index 6b5254fb..b425b62a 100644 --- a/init.zsh +++ b/init.zsh @@ -31,7 +31,7 @@ function pmodload { pmodules=("$argv[@]") # Add functions to $fpath. - fpath=(${pmodules:+${ZDOTDIR:-$HOME}/.zprezto/modules/${^pmodules}/functions(/FN)} $fpath) + fpath=(${pmodules:+$ZPREZTODIR/modules/${^pmodules}/functions(/FN)} $fpath) function { local pfunction @@ -40,7 +40,7 @@ function pmodload { setopt LOCAL_OPTIONS EXTENDED_GLOB # Load Prezto functions. - for pfunction in ${ZDOTDIR:-$HOME}/.zprezto/modules/${^pmodules}/functions/$~pfunction_glob; do + for pfunction in $ZPREZTODIR/modules/${^pmodules}/functions/$~pfunction_glob; do autoload -Uz "$pfunction" done } @@ -49,19 +49,19 @@ function pmodload { for pmodule in "$pmodules[@]"; do if zstyle -t ":prezto:module:$pmodule" loaded 'yes' 'no'; then continue - elif [[ ! -d "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule" ]]; then + elif [[ ! -d "$ZPREZTODIR/modules/$pmodule" ]]; then print "$0: no such module: $pmodule" >&2 continue else - if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/init.zsh" ]]; then - source "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/init.zsh" + if [[ -s "$ZPREZTODIR/modules/$pmodule/init.zsh" ]]; then + source "$ZPREZTODIR/modules/$pmodule/init.zsh" fi if (( $? == 0 )); then zstyle ":prezto:module:$pmodule" loaded 'yes' else # Remove the $fpath entry. - fpath[(r)${ZDOTDIR:-$HOME}/.zprezto/modules/${pmodule}/functions]=() + fpath[(r)${ZPREZTODIR}/modules/${pmodule}/functions]=() function { local pfunction @@ -71,7 +71,7 @@ function pmodload { setopt LOCAL_OPTIONS EXTENDED_GLOB # Unload Prezto functions. - for pfunction in ${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/functions/$~pfunction_glob; do + for pfunction in $ZPREZTODIR/modules/$pmodule/functions/$~pfunction_glob; do unfunction "$pfunction" done } @@ -86,6 +86,9 @@ function pmodload { # Prezto Initialization # +# Find the dir Prezto is installed to +ZPREZTODIR=${ZPREZTODIR:-${ZDOTDIR:-$HOME}/.zprezto} + # Source the Prezto configuration file. if [[ -s "${ZDOTDIR:-$HOME}/.zpreztorc" ]]; then source "${ZDOTDIR:-$HOME}/.zpreztorc"