1
0
Fork 0
mirror of synced 2024-11-26 17:25:35 -05:00

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

View file

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

View file

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