diff --git a/CHANGELOG.md b/CHANGELOG.md
index d62e57e..411ea86 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/README.md b/README.md
index 7d1459e..680082e 100644
--- a/README.md
+++ b/README.md
@@ -87,8 +87,8 @@ Usage: zmodule <url> [-n|--name<
Add zmodule calls to your ~/.zimrc 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: name, zimfw/name, https://github.com/zimfw/name.git.
+ <url> Module absolute path or repository URL. The following URL formats
+ are equivalent: name, zimfw/name, https://github.com/zimfw/name.git.
-n|--name <module_name> Set a custom module name. Default: the last component in the <url>.
Repository options:
diff --git a/src/stage2/29_zimfw_build_login_init.zsh.erb b/src/stage2/29_zimfw_build_login_init.zsh.erb
index 89eb2f1..3438828 100644
--- a/src/stage2/29_zimfw_build_login_init.zsh.erb
+++ b/src/stage2/29_zimfw_build_login_init.zsh.erb
@@ -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") %>"
diff --git a/src/stage2/30_zmodule.zsh.erb b/src/stage2/30_zmodule.zsh.erb
index e090498..e957ffb 100644
--- a/src/stage2/30_zmodule.zsh.erb
+++ b/src/stage2/30_zmodule.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.
- Required repository URL or path. The following formats are
- equivalent: %Bname%b, %Bzimfw/name%b, %Bhttps://github.com/zimfw/name.git%b.
+ 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 Set a custom module name. Default: the last component in the .
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)
diff --git a/src/stage2/80_zimfw.zsh.erb b/src/stage2/80_zimfw.zsh.erb
index 1710d8a..9501cc0 100644
--- a/src/stage2/80_zimfw.zsh.erb
+++ b/src/stage2/80_zimfw.zsh.erb
@@ -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)
diff --git a/src/templates/login_init.zsh.erb b/src/templates/login_init.zsh.erb
index 3076a44..fad8904 100644
--- a/src/templates/login_init.zsh.erb
+++ b/src/templates/login_init.zsh.erb
@@ -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.'
} "${@}"
diff --git a/src/zimfw.zsh.erb b/src/zimfw.zsh.erb
index b156412..2b80fae 100644
--- a/src/zimfw.zsh.erb
+++ b/src/zimfw.zsh.erb
@@ -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)
diff --git a/zimfw.zsh b/zimfw.zsh
index 552591d..357d17c 100644
--- a/zimfw.zsh
+++ b/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.
- Required repository URL or path. The following formats are
- equivalent: %Bname%b, %Bzimfw/name%b, %Bhttps://github.com/zimfw/name.git%b.
+ 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 Set a custom module name. Default: the last component in the .
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 [%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)