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]
|
## [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
|
## [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
|
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.
|
initialized in the same order they are defined.
|
||||||
|
|
||||||
<url> Required repository URL or path. The following formats are
|
<url> Module absolute path or repository URL. The following URL formats
|
||||||
equivalent: <strong>name</strong>, <strong>zimfw/name</strong>, <strong>https://github.com/zimfw/name.git</strong>.
|
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>.
|
<strong>-n</strong>|<strong>--name</strong> <module_name> Set a custom module name. Default: the last component in the <url>.
|
||||||
|
|
||||||
Repository options:
|
Repository options:
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
_zimfw_build_login_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
|
local -r ztarget=${ZIM_HOME}/login_init.zsh
|
||||||
_zimfw_mv =(
|
_zimfw_mv =(
|
||||||
print -Rn "<%= render_escaped("src/templates/login_init.zsh.erb") %>"
|
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.
|
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.
|
The modules are initialized in the same order they are defined.
|
||||||
|
|
||||||
<url> Required repository URL or path. The following formats are
|
<url> Module absolute path or repository URL. The following URL formats
|
||||||
equivalent: %Bname%b, %Bzimfw/name%b, %Bhttps://github.com/zimfw/name.git%b.
|
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>.
|
%B-n%b|%B--name%b <module_name> Set a custom module name. Default: the last component in the <url>.
|
||||||
|
|
||||||
Repository options:
|
Repository options:
|
||||||
|
@ -39,7 +39,7 @@ Initialization options:
|
||||||
local ztype=branch zrev=master
|
local ztype=branch zrev=master
|
||||||
local -i zdisabled=0 zfrozen=0
|
local -i zdisabled=0 zfrozen=0
|
||||||
local -a zfpaths zfunctions zscripts
|
local -a zfpaths zfunctions zscripts
|
||||||
local zarg
|
local zarg zdir
|
||||||
if [[ ${zurl} =~ ^[^:/]+: ]]; then
|
if [[ ${zurl} =~ ^[^:/]+: ]]; then
|
||||||
zmodule=${zmodule%.git}
|
zmodule=${zmodule%.git}
|
||||||
elif [[ ${zurl} != /* ]]; then
|
elif [[ ${zurl} != /* ]]; then
|
||||||
|
@ -60,7 +60,11 @@ Initialization options:
|
||||||
zmodule=${1}
|
zmodule=${1}
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
local -r zdir=${ZIM_HOME}/modules/${zmodule}
|
if [[ ${zurl} == /* ]]; then
|
||||||
|
zdir=${zurl}
|
||||||
|
else
|
||||||
|
zdir=${ZIM_HOME}/modules/${zmodule}
|
||||||
|
fi
|
||||||
while (( # > 0 )); do
|
while (( # > 0 )); do
|
||||||
case ${1} in
|
case ${1} in
|
||||||
-b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source)
|
-b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source)
|
||||||
|
|
|
@ -60,7 +60,7 @@ Options:
|
||||||
clean) _zimfw_clean_compiled && _zimfw_clean_dumpfile ;;
|
clean) _zimfw_clean_compiled && _zimfw_clean_dumpfile ;;
|
||||||
clean-compiled) _zimfw_clean_compiled ;;
|
clean-compiled) _zimfw_clean_compiled ;;
|
||||||
clean-dumpfile) _zimfw_clean_dumpfile ;;
|
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} ;;
|
help) print -PR ${zusage} ;;
|
||||||
info) _zimfw_info ;;
|
info) _zimfw_info ;;
|
||||||
install|update)
|
install|update)
|
||||||
|
|
|
@ -10,16 +10,14 @@
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Compile Zsh startup files
|
# 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
|
zrecompile -p ${1} ${zfile} || return 1
|
||||||
done
|
done
|
||||||
|
|
||||||
# Compile Zim scripts
|
# Compile Zim scripts
|
||||||
for zfile in ${ZIM_HOME}/(^*test*/)#*.zsh(|-theme)(N-.); do
|
for zfile in #{zscriptglob}; do
|
||||||
zrecompile -p ${1} ${zfile} || return 1
|
zrecompile -p ${1} ${zfile} || return 1
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ${1} != -q ]]; then
|
if [[ ${1} != -q ]] print -P '<%= done %>Done with compile.'
|
||||||
print -P '<%= done %>Done with compile.'
|
|
||||||
fi
|
|
||||||
} "${@}"
|
} "${@}"
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Zim
|
||||||
@home = "${ZDOTDIR:-${HOME}}"
|
@home = "${ZDOTDIR:-${HOME}}"
|
||||||
@min_zsh_version = "5.2"
|
@min_zsh_version = "5.2"
|
||||||
@startup_files_glob = ".z(shenv|profile|shrc|login|logout)"
|
@startup_files_glob = ".z(shenv|profile|shrc|login|logout)"
|
||||||
@version = "1.2.1"
|
@version = "1.2.2-SNAPSHOT"
|
||||||
@ellipsis = " ..."
|
@ellipsis = " ..."
|
||||||
@okay = "%F{green})%f "
|
@okay = "%F{green})%f "
|
||||||
@warn = "! "
|
@warn = "! "
|
||||||
|
@ -24,7 +24,7 @@ class Zim
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_escaped(filename)
|
def render_escaped(filename)
|
||||||
render(filename).gsub(/(?=\$[^']|"|`)/, "\\\\")
|
render(filename).gsub(/(?=\$[^']|"|`)/, "\\\\").gsub(/#\{/, "$\{")
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_commented(filename)
|
def render_commented(filename)
|
||||||
|
|
28
zimfw.zsh
28
zimfw.zsh
|
@ -65,6 +65,8 @@ _zimfw_build_init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_build_login_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
|
local -r ztarget=${ZIM_HOME}/login_init.zsh
|
||||||
_zimfw_mv =(
|
_zimfw_mv =(
|
||||||
print -Rn "() {
|
print -Rn "() {
|
||||||
|
@ -79,18 +81,16 @@ _zimfw_build_login_init() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Compile Zsh startup files
|
# 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
|
zrecompile -p \${1} \${zfile} || return 1
|
||||||
done
|
done
|
||||||
|
|
||||||
# Compile Zim scripts
|
# Compile Zim scripts
|
||||||
for zfile in \${ZIM_HOME}/(^*test*/)#*.zsh(|-theme)(N-.); do
|
for zfile in ${zscriptglob}; do
|
||||||
zrecompile -p \${1} \${zfile} || return 1
|
zrecompile -p \${1} \${zfile} || return 1
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ \${1} != -q ]]; then
|
if [[ \${1} != -q ]] print -P 'Done with compile.'
|
||||||
print -P 'Done with compile.'
|
|
||||||
fi
|
|
||||||
} \"\${@}\"
|
} \"\${@}\"
|
||||||
"
|
"
|
||||||
) ${ztarget}
|
) ${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.
|
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.
|
The modules are initialized in the same order they are defined.
|
||||||
|
|
||||||
<url> Required repository URL or path. The following formats are
|
<url> Module absolute path or repository URL. The following URL formats
|
||||||
equivalent: %Bname%b, %Bzimfw/name%b, %Bhttps://github.com/zimfw/name.git%b.
|
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>.
|
%B-n%b|%B--name%b <module_name> Set a custom module name. Default: the last component in the <url>.
|
||||||
|
|
||||||
Repository options:
|
Repository options:
|
||||||
|
@ -141,7 +141,7 @@ Initialization options:
|
||||||
local ztype=branch zrev=master
|
local ztype=branch zrev=master
|
||||||
local -i zdisabled=0 zfrozen=0
|
local -i zdisabled=0 zfrozen=0
|
||||||
local -a zfpaths zfunctions zscripts
|
local -a zfpaths zfunctions zscripts
|
||||||
local zarg
|
local zarg zdir
|
||||||
if [[ ${zurl} =~ ^[^:/]+: ]]; then
|
if [[ ${zurl} =~ ^[^:/]+: ]]; then
|
||||||
zmodule=${zmodule%.git}
|
zmodule=${zmodule%.git}
|
||||||
elif [[ ${zurl} != /* ]]; then
|
elif [[ ${zurl} != /* ]]; then
|
||||||
|
@ -162,7 +162,11 @@ Initialization options:
|
||||||
zmodule=${1}
|
zmodule=${1}
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
local -r zdir=${ZIM_HOME}/modules/${zmodule}
|
if [[ ${zurl} == /* ]]; then
|
||||||
|
zdir=${zurl}
|
||||||
|
else
|
||||||
|
zdir=${ZIM_HOME}/modules/${zmodule}
|
||||||
|
fi
|
||||||
while (( # > 0 )); do
|
while (( # > 0 )); do
|
||||||
case ${1} in
|
case ${1} in
|
||||||
-b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source)
|
-b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source)
|
||||||
|
@ -299,7 +303,7 @@ _zimfw_compile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_info() {
|
_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 'ZIM_HOME: '${ZIM_HOME}
|
||||||
print -R 'Zsh version: '${ZSH_VERSION}
|
print -R 'Zsh version: '${ZSH_VERSION}
|
||||||
print -R 'System info: '$(command uname -a)
|
print -R 'System info: '$(command uname -a)
|
||||||
|
@ -343,7 +347,7 @@ _zimfw_upgrade() {
|
||||||
}
|
}
|
||||||
|
|
||||||
zimfw() {
|
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]
|
local -r zusage="Usage: %B${0}%b <action> [%B-q%b|%B-v%b]
|
||||||
|
|
||||||
Actions:
|
Actions:
|
||||||
|
@ -482,7 +486,7 @@ fi
|
||||||
clean) _zimfw_clean_compiled && _zimfw_clean_dumpfile ;;
|
clean) _zimfw_clean_compiled && _zimfw_clean_dumpfile ;;
|
||||||
clean-compiled) _zimfw_clean_compiled ;;
|
clean-compiled) _zimfw_clean_compiled ;;
|
||||||
clean-dumpfile) _zimfw_clean_dumpfile ;;
|
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} ;;
|
help) print -PR ${zusage} ;;
|
||||||
info) _zimfw_info ;;
|
info) _zimfw_info ;;
|
||||||
install|update)
|
install|update)
|
||||||
|
|
Loading…
Reference in a new issue