Use `${HOME}` in generated static init.zsh script

Fixes #509
This commit is contained in:
Eric Nielsen 2023-05-06 19:38:25 -05:00
parent db96076cf0
commit 10c307f405
3 changed files with 17 additions and 15 deletions

View File

@ -5,8 +5,8 @@ _zimfw_build_init() {
command mv -f ${ztarget}{,.old} || return 1
fi
_zimfw_mv =(
print -R "zimfw() { source ${(q-)ZIM_HOME}/zimfw.zsh \"\${@}\" }"
print -R "zmodule() { source ${(q-)ZIM_HOME}/zimfw.zsh \"\${@}\" }"
print -R 'zimfw() { source '${${(qqq)ZIM_HOME}/${HOME}/\${HOME}}'/zimfw.zsh "${@}" }'
print -R 'zmodule() { source '${${(qqq)ZIM_HOME}/${HOME}/\${HOME}}'/zimfw.zsh "${@}" }'
local zroot_dir zpre
local -a zif_functions zif_cmds zroot_functions zroot_cmds
local -a zfunctions=(${_zfunctions}) zcmds=(${_zcmds})
@ -22,7 +22,7 @@ _zimfw_build_init() {
fi
done
zpre=$'*\0'
if (( ${#_zfpaths} )) print 'fpath=('${(q-)${_zfpaths#${~zpre}}:a}' ${fpath})'
if (( ${#_zfpaths} )) print 'fpath=('${${(qqq)${_zfpaths#${~zpre}}:a}/${HOME}/\${HOME}}' ${fpath})'
if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}}
for zroot_dir in ${_zroot_dirs}; do
zpre=${zroot_dir}$'\0'

View File

@ -179,11 +179,11 @@ Per-call initialization options:
shift
zarg=${1}
if [[ ${zarg} != /* ]] zarg=${zroot_dir}/${zarg}
zcmds+=("source ${(q-)zarg:a}")
zcmds+=('source '${(qqq)zarg:a})
;;
-c|--cmd)
shift
zcmds+=(${1//{}/${(q-)zroot_dir:a}})
zcmds+=(${1//{}/${(qqq)zroot_dir:a}})
;;
-d|--disabled) _zdisabled_root_dirs+=(${zroot_dir}) ;;
*)
@ -211,11 +211,11 @@ Per-call initialization options:
local -ra prezto_scripts=(${zroot_dir}/init.zsh(N))
if (( ${#zfpaths} && ${#prezto_scripts} )); then
# this follows the prezto module format, no need to check for other scripts
zcmds=('source '${(q-)^prezto_scripts:a})
zcmds=('source '${(qqq)^prezto_scripts:a})
else
# get script with largest size (descending `O`rder by `L`ength, and return only `[1]` first)
local -ra zscripts=(${zroot_dir}/(init.zsh|(${zname:t}|${zroot_dir:t}).(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
zcmds=('source '${(q-)^zscripts:a})
zcmds=('source '${(qqq)^zscripts:a})
fi
fi
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
@ -225,6 +225,7 @@ Per-call initialization options:
local -r zpre=${zroot_dir}$'\0'
_zfpaths+=(${zpre}${^zfpaths})
_zfunctions+=(${zpre}${^zfunctions})
zcmds=(${zcmds/${HOME}/\${HOME}})
_zcmds+=(${zpre}${^zcmds})
fi
}

View File

@ -57,8 +57,8 @@ _zimfw_build_init() {
command mv -f ${ztarget}{,.old} || return 1
fi
_zimfw_mv =(
print -R "zimfw() { source ${(q-)ZIM_HOME}/zimfw.zsh \"\${@}\" }"
print -R "zmodule() { source ${(q-)ZIM_HOME}/zimfw.zsh \"\${@}\" }"
print -R 'zimfw() { source '${${(qqq)ZIM_HOME}/${HOME}/\${HOME}}'/zimfw.zsh "${@}" }'
print -R 'zmodule() { source '${${(qqq)ZIM_HOME}/${HOME}/\${HOME}}'/zimfw.zsh "${@}" }'
local zroot_dir zpre
local -a zif_functions zif_cmds zroot_functions zroot_cmds
local -a zfunctions=(${_zfunctions}) zcmds=(${_zcmds})
@ -74,7 +74,7 @@ _zimfw_build_init() {
fi
done
zpre=$'*\0'
if (( ${#_zfpaths} )) print 'fpath=('${(q-)${_zfpaths#${~zpre}}:a}' ${fpath})'
if (( ${#_zfpaths} )) print 'fpath=('${${(qqq)${_zfpaths#${~zpre}}:a}/${HOME}/\${HOME}}' ${fpath})'
if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}}
for zroot_dir in ${_zroot_dirs}; do
zpre=${zroot_dir}$'\0'
@ -291,11 +291,11 @@ Per-call initialization options:
shift
zarg=${1}
if [[ ${zarg} != /* ]] zarg=${zroot_dir}/${zarg}
zcmds+=("source ${(q-)zarg:a}")
zcmds+=('source '${(qqq)zarg:a})
;;
-c|--cmd)
shift
zcmds+=(${1//{}/${(q-)zroot_dir:a}})
zcmds+=(${1//{}/${(qqq)zroot_dir:a}})
;;
-d|--disabled) _zdisabled_root_dirs+=(${zroot_dir}) ;;
*)
@ -323,11 +323,11 @@ Per-call initialization options:
local -ra prezto_scripts=(${zroot_dir}/init.zsh(N))
if (( ${#zfpaths} && ${#prezto_scripts} )); then
# this follows the prezto module format, no need to check for other scripts
zcmds=('source '${(q-)^prezto_scripts:a})
zcmds=('source '${(qqq)^prezto_scripts:a})
else
# get script with largest size (descending `O`rder by `L`ength, and return only `[1]` first)
local -ra zscripts=(${zroot_dir}/(init.zsh|(${zname:t}|${zroot_dir:t}).(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
zcmds=('source '${(q-)^zscripts:a})
zcmds=('source '${(qqq)^zscripts:a})
fi
fi
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
@ -337,6 +337,7 @@ Per-call initialization options:
local -r zpre=${zroot_dir}$'\0'
_zfpaths+=(${zpre}${^zfpaths})
_zfunctions+=(${zpre}${^zfunctions})
zcmds=(${zcmds/${HOME}/\${HOME}})
_zcmds+=(${zpre}${^zcmds})
fi
}
@ -433,7 +434,7 @@ _zimfw_compile() {
}
_zimfw_info() {
print -R 'zimfw version: '${_zversion}' (built at 2023-04-01 01:32:16 UTC, previous commit is 5db1155)'
print -R 'zimfw version: '${_zversion}' (built at 2023-05-04 00:03:05 UTC, previous commit is db96076)'
local zparam
for zparam in LANG ${(Mk)parameters:#LC_*} OSTYPE TERM TERM_PROGRAM TERM_PROGRAM_VERSION ZIM_HOME ZSH_VERSION; do
print -R ${(r.22....:.)zparam}${(P)zparam}