8dc3e43a0d
This is a major change, where Zsh modules/plugins are not git submodules in the Zim repo anymore, but customized and installed separately as individual repositories. The discussion about this started more than 2 years ago in #88. Closes #299. This will allow contributors' modules to live in their own repositories. See #33, #138, #262, #281, #324. The current code has what, up to this point, I considered to be the best balance between simplicity, execution speed and number of files. One measured decision was to make the initialization of modules depend only on the `':zim' modules` style, keeping it as fast as possible. The `':zim:module' module` style is used to install, update and clean the modules, all operations that happen after the user got his as-blazing-fast-possible shell prompt. Even though I didn't care much about making install or update fast, `xargs` has a nice feature of allowing commands to be executed in parallel with `-P`. I took advantage of that. I've also worked on making the `zimfw` utility give the user some nice (while still minimalistic) output. Also I'm suggesting this as the new name for the `zmanage` tool, since `zimfw` does not shadow the `zim` wiki tool.
25 lines
795 B
Bash
25 lines
795 B
Bash
local zmodule zurl ztype zrev
|
|
local -a zmodules
|
|
local -A zoptions
|
|
zstyle -a ':zim' modules 'zmodules'
|
|
for zmodule in ${zmodules}; do
|
|
zstyle -a ':zim:module' ${zmodule} 'zoptions'
|
|
[[ ${zoptions[frozen]} == yes ]] && continue
|
|
zurl=${zoptions[url]:-${zmodule}}
|
|
if [[ ${zurl} != /* && ${zurl} != *@*:* ]]; then
|
|
# Count number of slashes
|
|
case ${#zurl//[^\/]/} in
|
|
0) zurl="https://github.com/zimfw/${zurl}.git" ;;
|
|
1) zurl="https://github.com/${zurl}.git" ;;
|
|
esac
|
|
fi
|
|
if [[ -n ${zoptions[tag]} ]]; then
|
|
ztype=tag
|
|
zrev=${zoptions[tag]}
|
|
else
|
|
ztype=branch
|
|
zrev=${zoptions[branch]:-master}
|
|
fi
|
|
# Cannot have an empty space at the EOL because this is read by xargs -L1
|
|
print "${zurl} ${ZIM_HOME}/modules/${zmodule} ${ztype} ${zrev}${1:+ ${1}}"
|
|
done
|