1
0
Fork 0
mirror of synced 2024-05-27 12:31:12 -04:00
zimfw/src/stage2/30_zimfw_build.zsh.erb
Eric Nielsen 106335e1d8
Add zimfw init action for a quick build
Having to manually do `zimfw build` every time after you edit your
.zimrc file is boring. So by having the following in .zshrc before
sourcing init.zsh will do a quick build automatically when needed:

    if [[ ~/.zim/init.zsh -ot ~/.zimrc ]]; then
      source ~/.zim/zimfw.zsh init -q
    fi
2019-12-07 21:23:20 -05:00

27 lines
938 B
Plaintext

_zimfw_build() {
() {
local -r ztarget=${ZIM_HOME}/init.zsh
if [[ ${ztarget} -nt <%= home %>/.zimrc ]] && command cmp -s ${ztarget} ${1}; then
if (( ! _zquiet )); then
print -PR "%F{green}✓%f %B${ztarget}:%b Already up to date"
fi
else
if [[ -e ${ztarget} ]]; then
command mv -f ${ztarget}{,.old} || return 1
fi
command mv -f ${1} ${ztarget} && \
if (( ! _zquiet )); then
print -PR "%F{green}✓%f %B${ztarget}:%b Updated. Restart your terminal for changes to take effect."
fi
fi
if (( ! _zquiet )); then
print -P '%F{green}✓%f Done with build.'
fi
} =(
print -R "zimfw() { source ${ZIM_HOME}/<%= script_filename %> \"\${@}\" }"
(( ${#_zfpaths} )) && print -R 'fpath=('${_zfpaths:P}' ${fpath})'
(( ${#_zfunctions} )) && print -R 'autoload -Uz '${_zfunctions}
print -Rn ${(F):-source ${^_zscripts:P}}
)
}