1980ca091d
Also moved the templates out of this repository, and into the zimfw/install repo. This is a second big change after introducing the plugin mechanism. This makes installation and upgrading of Zim straightforward. Maybe the most important aspect of having the script in a single file is not having to manage "git repos inside git repos" (see #297), since the single file exists by itself and is not version-controlled (with git). I've implemented a two-stage sourcing of the file, so most of the file is only sourced when needed (namely when calling `zimfw` with any action other than `login-init`). The two-stage process is designed to avoid compromising the startup speed, which is our top priority. In an effort to help making the script maintainable, I've broken it into small ERB templates. This also adds the ability to pre-process the Zsh code with Ruby code. To build the script, use `make`.
58 lines
1.6 KiB
Plaintext
58 lines
1.6 KiB
Plaintext
unfunction zimfw
|
|
zimfw() {
|
|
local zusage="usage: ${0} <action> [-q]
|
|
actions:
|
|
clean Clean all (see below).
|
|
clean-modules Clean unused modules.
|
|
clean-compiled Clean Zsh compiled files.
|
|
clean-dumpfile Clean completion dump file.
|
|
compile Compile Zsh files.
|
|
info Print Zim and system info.
|
|
install Install new modules.
|
|
update Update current modules.
|
|
upgrade Upgrade Zim.
|
|
options:
|
|
-q Quiet, only outputs errors."
|
|
|
|
if [[ ${#} -ne 1 && ${2} != -q ]]; then
|
|
print -u2 ${zusage}
|
|
return 1
|
|
fi
|
|
|
|
local ztool
|
|
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
|
|
clean)
|
|
_zimfw_clean_modules ${2} && \
|
|
_zimfw_clean_compiled ${2} && \
|
|
_zimfw_clean_dumpfile ${2}
|
|
;;
|
|
clean-modules) _zimfw_clean_modules ${2} ;;
|
|
clean-compiled) _zimfw_clean_compiled ${2} ;;
|
|
clean-dumpfile) _zimfw_clean_dumpfile ${2} ;;
|
|
compile|login-init) _zimfw_compile ${2} ;;
|
|
info) _zimfw_info ${2} ;;
|
|
install|update)
|
|
# Source .zimrc to refresh zmodules
|
|
[[ -f <%= home %>/.zimrc ]] && source <%= home %>/.zimrc
|
|
_zimfw_modules ${2} | xargs -L1 -P10 zsh -c ${ztool} ${1} && \
|
|
if [[ ${2} != -q ]]; then
|
|
print -P "%F{green}✓%f Done with ${1}. Restart your terminal for any changes to take effect."
|
|
fi
|
|
;;
|
|
upgrade) _zimfw_upgrade ${2} ;;
|
|
*)
|
|
print -u2 ${zusage}
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|