1
0
Fork 0
mirror of synced 2024-11-22 15:25:34 -05:00

Source .zimrc twice when installing/updating

Once before installing/updating to prepare _zmodule_xargs, and once
after modules are updated, so functions and scripts can be found inside
them. Installation of Zim from scratch was failing because all modules
are empty at first.
This commit is contained in:
Eric Nielsen 2019-12-03 07:07:59 -05:00
parent dfe35e1bfa
commit a227f134a5
No known key found for this signature in database
GPG key ID: 47D1DBFA0765A1FB
4 changed files with 46 additions and 38 deletions

View file

@ -96,24 +96,27 @@ Startup options:
esac esac
shift shift
done done
if (( zdisabled )); then if (( _zprepare_xargs )); then
_zdisableds+=(${zmodule}) if (( ! zfrozen )); then
_zmodules_xargs+=${zmodule}$'\0'${zdir}$'\0'${zurl}$'\0'${ztype}$'\0'${zrev}$'\0'${_zquiet}$'\0'
fi
else else
(( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF)) if (( zdisabled )); then
if (( ! ${#zfunctions} )); then _zdisableds+=(${zmodule})
# _* functions are autoloaded by compinit else
# prompt_*_setup functions are autoloaded by promptinit (( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF))
zfunctions+=(${^zfpaths}/^(*.*|_*|prompt_*_setup)(N-.:t)) if (( ! ${#zfunctions} )); then
# _* functions are autoloaded by compinit
# prompt_*_setup functions are autoloaded by promptinit
zfunctions+=(${^zfpaths}/^(*.*|_*|prompt_*_setup)(N-.:t))
fi
if (( ! ${#zscripts} )); then
zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
fi
_zfpaths+=(${zfpaths})
_zfunctions+=(${zfunctions})
_zscripts+=(${zscripts})
_zmodules+=(${zmodule})
fi fi
if (( ! ${#zscripts} )); then
zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
fi
_zfpaths+=(${zfpaths})
_zfunctions+=(${zfunctions})
_zscripts+=(${zscripts})
_zmodules+=(${zmodule})
fi
if (( ! zfrozen )); then
_zmodules_xargs+=${zmodule}$'\0'${zdir}$'\0'${zurl}$'\0'${ztype}$'\0'${zrev}$'\0'${_zquiet}$'\0'
fi fi
} }

View file

@ -1,4 +1,5 @@
_zimfw_source_zimrc() { _zimfw_source_zimrc() {
local -ri _zprepare_xargs=${1}
local -i _zfailed=0 local -i _zfailed=0
if ! source <%= home %>/.zimrc || (( _zfailed )); then if ! source <%= home %>/.zimrc || (( _zfailed )); then
print -u2 -PR "%F{red}✗ Failed to source <%= home %>/.zimrc%f" print -u2 -PR "%F{red}✗ Failed to source <%= home %>/.zimrc%f"

View file

@ -56,12 +56,12 @@ Options:
compile|login-init) _zimfw_source_zimrc && _zimfw_compile ${2} ;; compile|login-init) _zimfw_source_zimrc && _zimfw_compile ${2} ;;
info) _zimfw_info ;; info) _zimfw_info ;;
install|update) install|update)
_zimfw_source_zimrc || return 1 _zimfw_source_zimrc 1 || return 1
print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \ print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -PR "%F{green}✓%f Done with ${1}. Restart your terminal for any changes to take effect." print -PR "%F{green}✓%f Done with ${1}. Restart your terminal for any changes to take effect."
fi && \ fi && \
_zimfw_build && _zimfw_compile ${2} _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2}
;; ;;
upgrade) _zimfw_upgrade ;; upgrade) _zimfw_upgrade ;;
*) *)

View file

@ -171,29 +171,33 @@ Startup options:
esac esac
shift shift
done done
if (( zdisabled )); then if (( _zprepare_xargs )); then
_zdisableds+=(${zmodule}) if (( ! zfrozen )); then
_zmodules_xargs+=${zmodule}$'\0'${zdir}$'\0'${zurl}$'\0'${ztype}$'\0'${zrev}$'\0'${_zquiet}$'\0'
fi
else else
(( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF)) if (( zdisabled )); then
if (( ! ${#zfunctions} )); then _zdisableds+=(${zmodule})
# _* functions are autoloaded by compinit else
# prompt_*_setup functions are autoloaded by promptinit (( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF))
zfunctions+=(${^zfpaths}/^(*.*|_*|prompt_*_setup)(N-.:t)) if (( ! ${#zfunctions} )); then
# _* functions are autoloaded by compinit
# prompt_*_setup functions are autoloaded by promptinit
zfunctions+=(${^zfpaths}/^(*.*|_*|prompt_*_setup)(N-.:t))
fi
if (( ! ${#zscripts} )); then
zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
fi
_zfpaths+=(${zfpaths})
_zfunctions+=(${zfunctions})
_zscripts+=(${zscripts})
_zmodules+=(${zmodule})
fi fi
if (( ! ${#zscripts} )); then
zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
fi
_zfpaths+=(${zfpaths})
_zfunctions+=(${zfunctions})
_zscripts+=(${zscripts})
_zmodules+=(${zmodule})
fi
if (( ! zfrozen )); then
_zmodules_xargs+=${zmodule}$'\0'${zdir}$'\0'${zurl}$'\0'${ztype}$'\0'${zrev}$'\0'${_zquiet}$'\0'
fi fi
} }
_zimfw_source_zimrc() { _zimfw_source_zimrc() {
local -ri _zprepare_xargs=${1}
local -i _zfailed=0 local -i _zfailed=0
if ! source ${ZDOTDIR:-${HOME}}/.zimrc || (( _zfailed )); then if ! source ${ZDOTDIR:-${HOME}}/.zimrc || (( _zfailed )); then
print -u2 -PR "%F{red}✗ Failed to source ${ZDOTDIR:-${HOME}}/.zimrc%f" print -u2 -PR "%F{red}✗ Failed to source ${ZDOTDIR:-${HOME}}/.zimrc%f"
@ -416,12 +420,12 @@ fi
compile|login-init) _zimfw_source_zimrc && _zimfw_compile ${2} ;; compile|login-init) _zimfw_source_zimrc && _zimfw_compile ${2} ;;
info) _zimfw_info ;; info) _zimfw_info ;;
install|update) install|update)
_zimfw_source_zimrc || return 1 _zimfw_source_zimrc 1 || return 1
print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \ print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \
if (( ! _zquiet )); then if (( ! _zquiet )); then
print -PR "%F{green}✓%f Done with ${1}. Restart your terminal for any changes to take effect." print -PR "%F{green}✓%f Done with ${1}. Restart your terminal for any changes to take effect."
fi && \ fi && \
_zimfw_build && _zimfw_compile ${2} _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2}
;; ;;
upgrade) _zimfw_upgrade ;; upgrade) _zimfw_upgrade ;;
*) *)