Init and compile local modules in their directories
instead of requiring that they're installed inside ZIM_HOME. Fixes #399
This commit is contained in:
parent
9890c9d503
commit
99e6b31891
8 changed files with 37 additions and 27 deletions
|
@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
_No unreleased changes._
|
||||
### Fixed
|
||||
- Allow local modules to be initialized and compiled in their respective
|
||||
directories, instead of forcing them to be "installed" inside `ZIM_HOME`.
|
||||
|
||||
## [1.2.1] - 2020-05-26
|
||||
|
||||
|
|
|
@ -87,8 +87,8 @@ Usage: <strong>zmodule</strong> <url> [<strong>-n</strong>|<strong>--name<
|
|||
Add <strong>zmodule</strong> calls to your <strong>~/.zimrc</strong> file to define the modules to be initialized. The modules are
|
||||
initialized in the same order they are defined.
|
||||
|
||||
<url> Required repository URL or path. The following formats are
|
||||
equivalent: <strong>name</strong>, <strong>zimfw/name</strong>, <strong>https://github.com/zimfw/name.git</strong>.
|
||||
<url> Module absolute path or repository URL. The following URL formats
|
||||
are equivalent: <strong>name</strong>, <strong>zimfw/name</strong>, <strong>https://github.com/zimfw/name.git</strong>.
|
||||
<strong>-n</strong>|<strong>--name</strong> <module_name> Set a custom module name. Default: the last component in the <url>.
|
||||
|
||||
Repository options:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
_zimfw_build_login_init() {
|
||||
local -Ur zscriptdirs=(${ZIM_HOME} ${${_zscripts%%${ZIM_HOME}/*}:h})
|
||||
local -r zscriptglob=("${^zscriptdirs[@]}/(^*test*/)#*.zsh(|-theme)(N-.)")
|
||||
local -r ztarget=${ZIM_HOME}/login_init.zsh
|
||||
_zimfw_mv =(
|
||||
print -Rn "<%= render_escaped("src/templates/login_init.zsh.erb") %>"
|
||||
|
|
|
@ -4,8 +4,8 @@ zmodule() {
|
|||
Add %Bzmodule%b calls to your %B${ZDOTDIR:-${HOME}}/.zimrc%b file to define the modules to be initialized.
|
||||
The modules are initialized in the same order they are defined.
|
||||
|
||||
<url> Required repository URL or path. The following formats are
|
||||
equivalent: %Bname%b, %Bzimfw/name%b, %Bhttps://github.com/zimfw/name.git%b.
|
||||
<url> Module absolute path or repository URL. The following URL formats
|
||||
are equivalent: %Bname%b, %Bzimfw/name%b, %Bhttps://github.com/zimfw/name.git%b.
|
||||
%B-n%b|%B--name%b <module_name> Set a custom module name. Default: the last component in the <url>.
|
||||
|
||||
Repository options:
|
||||
|
@ -39,7 +39,7 @@ Initialization options:
|
|||
local ztype=branch zrev=master
|
||||
local -i zdisabled=0 zfrozen=0
|
||||
local -a zfpaths zfunctions zscripts
|
||||
local zarg
|
||||
local zarg zdir
|
||||
if [[ ${zurl} =~ ^[^:/]+: ]]; then
|
||||
zmodule=${zmodule%.git}
|
||||
elif [[ ${zurl} != /* ]]; then
|
||||
|
@ -60,7 +60,11 @@ Initialization options:
|
|||
zmodule=${1}
|
||||
shift
|
||||
fi
|
||||
local -r zdir=${ZIM_HOME}/modules/${zmodule}
|
||||
if [[ ${zurl} == /* ]]; then
|
||||
zdir=${zurl}
|
||||
else
|
||||
zdir=${ZIM_HOME}/modules/${zmodule}
|
||||
fi
|
||||
while (( # > 0 )); do
|
||||
case ${1} in
|
||||
-b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source)
|
||||
|
|
|
@ -60,7 +60,7 @@ Options:
|
|||
clean) _zimfw_clean_compiled && _zimfw_clean_dumpfile ;;
|
||||
clean-compiled) _zimfw_clean_compiled ;;
|
||||
clean-dumpfile) _zimfw_clean_dumpfile ;;
|
||||
compile) _zimfw_build_login_init && _zimfw_compile ;;
|
||||
compile) _zimfw_source_zimrc && _zimfw_build_login_init && _zimfw_compile ;;
|
||||
help) print -PR ${zusage} ;;
|
||||
info) _zimfw_info ;;
|
||||
install|update)
|
||||
|
|
|
@ -10,16 +10,14 @@
|
|||
fi
|
||||
|
||||
# Compile Zsh startup files
|
||||
for zfile in ${1} <%= home %>/<%= startup_files_glob %>(N-.); do
|
||||
for zfile in <%= home %>/<%= startup_files_glob %>(N-.); do
|
||||
zrecompile -p ${1} ${zfile} || return 1
|
||||
done
|
||||
|
||||
# Compile Zim scripts
|
||||
for zfile in ${ZIM_HOME}/(^*test*/)#*.zsh(|-theme)(N-.); do
|
||||
for zfile in #{zscriptglob}; do
|
||||
zrecompile -p ${1} ${zfile} || return 1
|
||||
done
|
||||
|
||||
if [[ ${1} != -q ]]; then
|
||||
print -P '<%= done %>Done with compile.'
|
||||
fi
|
||||
if [[ ${1} != -q ]] print -P '<%= done %>Done with compile.'
|
||||
} "${@}"
|
||||
|
|
|
@ -6,7 +6,7 @@ class Zim
|
|||
@home = "${ZDOTDIR:-${HOME}}"
|
||||
@min_zsh_version = "5.2"
|
||||
@startup_files_glob = ".z(shenv|profile|shrc|login|logout)"
|
||||
@version = "1.2.1"
|
||||
@version = "1.2.2-SNAPSHOT"
|
||||
@ellipsis = " ..."
|
||||
@okay = "%F{green})%f "
|
||||
@warn = "! "
|
||||
|
@ -24,7 +24,7 @@ class Zim
|
|||
end
|
||||
|
||||
def render_escaped(filename)
|
||||
render(filename).gsub(/(?=\$[^']|"|`)/, "\\\\")
|
||||
render(filename).gsub(/(?=\$[^']|"|`)/, "\\\\").gsub(/#\{/, "$\{")
|
||||
end
|
||||
|
||||
def render_commented(filename)
|
||||
|
|
28
zimfw.zsh
28
zimfw.zsh
|
@ -65,6 +65,8 @@ _zimfw_build_init() {
|
|||
}
|
||||
|
||||
_zimfw_build_login_init() {
|
||||
local -Ur zscriptdirs=(${ZIM_HOME} ${${_zscripts%%${ZIM_HOME}/*}:h})
|
||||
local -r zscriptglob=("${^zscriptdirs[@]}/(^*test*/)#*.zsh(|-theme)(N-.)")
|
||||
local -r ztarget=${ZIM_HOME}/login_init.zsh
|
||||
_zimfw_mv =(
|
||||
print -Rn "() {
|
||||
|
@ -79,18 +81,16 @@ _zimfw_build_login_init() {
|
|||
fi
|
||||
|
||||
# Compile Zsh startup files
|
||||
for zfile in \${1} \${ZDOTDIR:-\${HOME}}/.z(shenv|profile|shrc|login|logout)(N-.); do
|
||||
for zfile in \${ZDOTDIR:-\${HOME}}/.z(shenv|profile|shrc|login|logout)(N-.); do
|
||||
zrecompile -p \${1} \${zfile} || return 1
|
||||
done
|
||||
|
||||
# Compile Zim scripts
|
||||
for zfile in \${ZIM_HOME}/(^*test*/)#*.zsh(|-theme)(N-.); do
|
||||
for zfile in ${zscriptglob}; do
|
||||
zrecompile -p \${1} \${zfile} || return 1
|
||||
done
|
||||
|
||||
if [[ \${1} != -q ]]; then
|
||||
print -P 'Done with compile.'
|
||||
fi
|
||||
if [[ \${1} != -q ]] print -P 'Done with compile.'
|
||||
} \"\${@}\"
|
||||
"
|
||||
) ${ztarget}
|
||||
|
@ -106,8 +106,8 @@ zmodule() {
|
|||
Add %Bzmodule%b calls to your %B${ZDOTDIR:-${HOME}}/.zimrc%b file to define the modules to be initialized.
|
||||
The modules are initialized in the same order they are defined.
|
||||
|
||||
<url> Required repository URL or path. The following formats are
|
||||
equivalent: %Bname%b, %Bzimfw/name%b, %Bhttps://github.com/zimfw/name.git%b.
|
||||
<url> Module absolute path or repository URL. The following URL formats
|
||||
are equivalent: %Bname%b, %Bzimfw/name%b, %Bhttps://github.com/zimfw/name.git%b.
|
||||
%B-n%b|%B--name%b <module_name> Set a custom module name. Default: the last component in the <url>.
|
||||
|
||||
Repository options:
|
||||
|
@ -141,7 +141,7 @@ Initialization options:
|
|||
local ztype=branch zrev=master
|
||||
local -i zdisabled=0 zfrozen=0
|
||||
local -a zfpaths zfunctions zscripts
|
||||
local zarg
|
||||
local zarg zdir
|
||||
if [[ ${zurl} =~ ^[^:/]+: ]]; then
|
||||
zmodule=${zmodule%.git}
|
||||
elif [[ ${zurl} != /* ]]; then
|
||||
|
@ -162,7 +162,11 @@ Initialization options:
|
|||
zmodule=${1}
|
||||
shift
|
||||
fi
|
||||
local -r zdir=${ZIM_HOME}/modules/${zmodule}
|
||||
if [[ ${zurl} == /* ]]; then
|
||||
zdir=${zurl}
|
||||
else
|
||||
zdir=${ZIM_HOME}/modules/${zmodule}
|
||||
fi
|
||||
while (( # > 0 )); do
|
||||
case ${1} in
|
||||
-b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source)
|
||||
|
@ -299,7 +303,7 @@ _zimfw_compile() {
|
|||
}
|
||||
|
||||
_zimfw_info() {
|
||||
print -R 'zimfw version: '${_zversion}' (previous commit is c0d7862)'
|
||||
print -R 'zimfw version: '${_zversion}' (previous commit is 9890c9d)'
|
||||
print -R 'ZIM_HOME: '${ZIM_HOME}
|
||||
print -R 'Zsh version: '${ZSH_VERSION}
|
||||
print -R 'System info: '$(command uname -a)
|
||||
|
@ -343,7 +347,7 @@ _zimfw_upgrade() {
|
|||
}
|
||||
|
||||
zimfw() {
|
||||
local -r _zversion='1.2.1'
|
||||
local -r _zversion='1.2.2-SNAPSHOT'
|
||||
local -r zusage="Usage: %B${0}%b <action> [%B-q%b|%B-v%b]
|
||||
|
||||
Actions:
|
||||
|
@ -482,7 +486,7 @@ fi
|
|||
clean) _zimfw_clean_compiled && _zimfw_clean_dumpfile ;;
|
||||
clean-compiled) _zimfw_clean_compiled ;;
|
||||
clean-dumpfile) _zimfw_clean_dumpfile ;;
|
||||
compile) _zimfw_build_login_init && _zimfw_compile ;;
|
||||
compile) _zimfw_source_zimrc && _zimfw_build_login_init && _zimfw_compile ;;
|
||||
help) print -PR ${zusage} ;;
|
||||
info) _zimfw_info ;;
|
||||
install|update)
|
||||
|
|
Loading…
Reference in a new issue