106335e1d8
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
74 lines
2.2 KiB
Plaintext
74 lines
2.2 KiB
Plaintext
zimfw() {
|
|
local -r zusage="
|
|
Usage: %B${0}%b <action> [%B-q%b]
|
|
|
|
Actions:
|
|
%Bbuild%b Build init.zsh
|
|
%Bclean%b Clean all (see below)
|
|
%Bclean-modules%b Clean unused modules
|
|
%Bclean-compiled%b Clean Zsh compiled files
|
|
%Bclean-dumpfile%b Clean completion dump file
|
|
%Bcompile%b Compile Zsh files
|
|
%Binfo%b Print Zim and system info
|
|
%Binstall%b Install new modules
|
|
%Bupdate%b Update current modules
|
|
%Bupgrade%b Upgrade <%= script_filename %>
|
|
|
|
Options:
|
|
%B-q%b Quiet, only outputs errors
|
|
"
|
|
local ztool _zmodules_xargs
|
|
local -a _zdisableds _zmodules _zfpaths _zfunctions _zscripts
|
|
local -i _zquiet=0
|
|
if (( # > 2 )); then
|
|
print -u2 -PR "%F{red}${0}: Too many options%f"$'\n'${zusage}
|
|
return 1
|
|
elif (( # > 1 )); then
|
|
case ${2} in
|
|
-q) _zquiet=1 ;;
|
|
*)
|
|
print -u2 -PR "%F{red}${0}: Unknown option ${2}%f"$'\n'${zusage}
|
|
return 1
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
case ${1} in
|
|
install)
|
|
ztool="<%= render_escaped("src/tools/install.zsh.erb") %>"
|
|
;;
|
|
update)
|
|
ztool="<%= render_escaped("src/tools/update.zsh.erb") %>"
|
|
;;
|
|
esac
|
|
|
|
case ${1} in
|
|
build) _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} ;;
|
|
init) _zimfw_source_zimrc && _zimfw_build ;;
|
|
clean)
|
|
_zimfw_source_zimrc && \
|
|
_zimfw_clean_modules && \
|
|
_zimfw_clean_compiled && \
|
|
_zimfw_clean_dumpfile
|
|
;;
|
|
clean-modules) _zimfw_source_zimrc && _zimfw_clean_modules ;;
|
|
clean-compiled) _zimfw_clean_compiled ;;
|
|
clean-dumpfile) _zimfw_clean_dumpfile ;;
|
|
compile|login-init) _zimfw_source_zimrc && _zimfw_compile ${2} ;;
|
|
info) _zimfw_info ;;
|
|
install|update)
|
|
_zimfw_source_zimrc 1 || return 1
|
|
print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \
|
|
if (( ! _zquiet )); then
|
|
print -PR "%F{green}✓%f Done with ${1}. Restart your terminal for any changes to take effect."
|
|
fi && \
|
|
_zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2}
|
|
;;
|
|
upgrade) _zimfw_upgrade && _zimfw_compile ;;
|
|
*)
|
|
print -u2 -PR "%F{red}${0}: Unknown action ${1}%f"$'\n'${zusage}
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|