1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-22 16:18:00 +00:00

Allow setting ZPREZTODIR to make prezto easier to integrate with

This commit is contained in:
Kaleb Elwert 2017-03-07 17:42:41 -08:00
parent 4f19700919
commit 7346efd206

View File

@ -31,7 +31,7 @@ function pmodload {
pmodules=("$argv[@]") pmodules=("$argv[@]")
# Add functions to $fpath. # Add functions to $fpath.
fpath=(${pmodules:+${ZDOTDIR:-$HOME}/.zprezto/modules/${^pmodules}/functions(/FN)} $fpath) fpath=(${pmodules:+$ZPREZTODIR/modules/${^pmodules}/functions(/FN)} $fpath)
function { function {
local pfunction local pfunction
@ -40,7 +40,7 @@ function pmodload {
setopt LOCAL_OPTIONS EXTENDED_GLOB setopt LOCAL_OPTIONS EXTENDED_GLOB
# Load Prezto functions. # 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" autoload -Uz "$pfunction"
done done
} }
@ -49,19 +49,19 @@ function pmodload {
for pmodule in "$pmodules[@]"; do for pmodule in "$pmodules[@]"; do
if zstyle -t ":prezto:module:$pmodule" loaded 'yes' 'no'; then if zstyle -t ":prezto:module:$pmodule" loaded 'yes' 'no'; then
continue continue
elif [[ ! -d "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule" ]]; then elif [[ ! -d "$ZPREZTODIR/modules/$pmodule" ]]; then
print "$0: no such module: $pmodule" >&2 print "$0: no such module: $pmodule" >&2
continue continue
else else
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/init.zsh" ]]; then if [[ -s "$ZPREZTODIR/modules/$pmodule/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/init.zsh" source "$ZPREZTODIR/modules/$pmodule/init.zsh"
fi fi
if (( $? == 0 )); then if (( $? == 0 )); then
zstyle ":prezto:module:$pmodule" loaded 'yes' zstyle ":prezto:module:$pmodule" loaded 'yes'
else else
# Remove the $fpath entry. # Remove the $fpath entry.
fpath[(r)${ZDOTDIR:-$HOME}/.zprezto/modules/${pmodule}/functions]=() fpath[(r)${ZPREZTODIR}/modules/${pmodule}/functions]=()
function { function {
local pfunction local pfunction
@ -71,7 +71,7 @@ function pmodload {
setopt LOCAL_OPTIONS EXTENDED_GLOB setopt LOCAL_OPTIONS EXTENDED_GLOB
# Unload Prezto functions. # 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" unfunction "$pfunction"
done done
} }
@ -86,6 +86,9 @@ function pmodload {
# Prezto Initialization # Prezto Initialization
# #
# Find the dir Prezto is installed to
ZPREZTODIR=${ZPREZTODIR:-${ZDOTDIR:-$HOME}/.zprezto}
# Source the Prezto configuration file. # Source the Prezto configuration file.
if [[ -s "${ZDOTDIR:-$HOME}/.zpreztorc" ]]; then if [[ -s "${ZDOTDIR:-$HOME}/.zpreztorc" ]]; then
source "${ZDOTDIR:-$HOME}/.zpreztorc" source "${ZDOTDIR:-$HOME}/.zpreztorc"