diff --git a/CHANGELOG.md b/CHANGELOG.md
index 092902a..ec7b730 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
-_No unreleased changes._
+### Added
+- `-c|-cmd` option to `zmodule`.
## [1.2.2] - 2020-06-10
diff --git a/README.md b/README.md
index c5b1bb5..f6b4be7 100644
--- a/README.md
+++ b/README.md
@@ -102,6 +102,9 @@ Initialization options:
-s|--source <file_path> Source specified file. The file path is relative to the module root
directory. Default: the file with largest size matching
{init.zsh,module_name.{zsh,plugin.zsh,zsh-theme,sh}}, if any exist.
+ -c|--cmd <command> Execute specified command. Occurrences of the {} placeholder in the
+ command are subsituted by the module root directory path.
+ -s 'script.zsh' and -c 'source {}/script.zsh' are equivalent.
-d|--disabled Don't initialize or uninstall the module.
diff --git a/src/stage2/29_zimfw_build_init.zsh.erb b/src/stage2/29_zimfw_build_init.zsh.erb
index 71c1aa2..54d4349 100644
--- a/src/stage2/29_zimfw_build_init.zsh.erb
+++ b/src/stage2/29_zimfw_build_init.zsh.erb
@@ -8,6 +8,6 @@ _zimfw_build_init() {
print -R "zimfw() { source ${ZIM_HOME}/zimfw.zsh \"\${@}\" }"
if (( ${#_zfpaths} )) print -R 'fpath=('${_zfpaths:A}' ${fpath})'
if (( ${#_zfunctions} )) print -R 'autoload -Uz '${_zfunctions}
- print -Rn ${(F):-source ${^_zscripts:A}}
+ print -R ${(F)_zcmds}
) ${ztarget}
}
diff --git a/src/stage2/29_zimfw_build_login_init.zsh.erb b/src/stage2/29_zimfw_build_login_init.zsh.erb
index 3438828..a027415 100644
--- a/src/stage2/29_zimfw_build_login_init.zsh.erb
+++ b/src/stage2/29_zimfw_build_login_init.zsh.erb
@@ -1,5 +1,5 @@
_zimfw_build_login_init() {
- local -Ur zscriptdirs=(${ZIM_HOME} ${${_zscripts%%${ZIM_HOME}/*}:h})
+ local -Ur zscriptdirs=('${ZIM_HOME}' ${${_zdirs%%${ZIM_HOME}/*}:A})
local -r zscriptglob=("${^zscriptdirs[@]}/(^*test*/)#*.zsh(|-theme)(N-.)")
local -r ztarget=${ZIM_HOME}/login_init.zsh
_zimfw_mv =(
diff --git a/src/stage2/30_zmodule.zsh.erb b/src/stage2/30_zmodule.zsh.erb
index e957ffb..f007444 100644
--- a/src/stage2/30_zmodule.zsh.erb
+++ b/src/stage2/30_zmodule.zsh.erb
@@ -23,6 +23,9 @@ Initialization options:
%B-s%b|%B--source%b Source specified file. The file path is relative to the module root
directory. Default: the file with largest size matching
%B{init.zsh,module_name.{zsh,plugin.zsh,zsh-theme,sh}}%b, if any exist.
+ %B-c%b|%B--cmd%b Execute specified command. Occurrences of the %B{}%b placeholder in the
+ command are subsituted by the module root directory path.
+ %B-s 'script.zsh'%b and %B-c 'source {}/script.zsh'%b are equivalent.
%B-d%b|%B--disabled%b Don't initialize or uninstall the module.
"
if [[ ${${funcfiletrace[1]%:*}:t} != .zimrc ]]; then
@@ -38,7 +41,7 @@ Initialization options:
local zmodule=${1:t} zurl=${1}
local ztype=branch zrev=master
local -i zdisabled=0 zfrozen=0
- local -a zfpaths zfunctions zscripts
+ local -a zfpaths zfunctions zcmds
local zarg zdir
if [[ ${zurl} =~ ^[^:/]+: ]]; then
zmodule=${zmodule%.git}
@@ -101,7 +104,11 @@ Initialization options:
shift
zarg=${1}
if [[ ${zarg} != /* ]] zarg=${zdir}/${zarg}
- zscripts+=(${zarg})
+ zcmds+=("source ${zarg:A}")
+ ;;
+ -c|--cmd)
+ shift
+ zcmds+=(${1//{}/${zdir:A}})
;;
-d|--disabled) zdisabled=1 ;;
*)
@@ -131,16 +138,18 @@ Initialization options:
# prompt_*_setup functions are autoloaded by promptinit
zfunctions+=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t))
fi
- if (( ! ${#zscripts} )); then
- zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
+ if (( ! ${#zcmds} )); then
+ local -r zscript=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
+ zcmds+=("source ${^zscript[@]:A}")
fi
- if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zscripts} )); then
+ if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
print -u2 -PR "%F{yellow}<%= warn %>${funcfiletrace[1]}:%B${zmodule}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f"$'\n\n'${zusage}
fi
+ _zmodules+=(${zmodule})
+ _zdirs+=(${zdir})
_zfpaths+=(${zfpaths})
_zfunctions+=(${zfunctions})
- _zscripts+=(${zscripts})
- _zmodules+=(${zmodule})
+ _zcmds+=(${zcmds})
fi
fi
}
diff --git a/src/stage2/80_zimfw.zsh.erb b/src/stage2/80_zimfw.zsh.erb
index 9501cc0..56d7f8f 100644
--- a/src/stage2/80_zimfw.zsh.erb
+++ b/src/stage2/80_zimfw.zsh.erb
@@ -21,7 +21,7 @@ Options:
%B-v%b Verbose
"
local ztool
- local -a _zdisableds _zmodules _zfpaths _zfunctions _zscripts _zmodules_zargs
+ local -a _zdisableds _zmodules _zdirs _zfpaths _zfunctions _zcmds _zmodules_zargs
local -i _zprintlevel=1
if (( # > 2 )); then
print -u2 -PR "%F{red}${0}: Too many options%f"$'\n\n'${zusage}
diff --git a/src/zimfw.zsh.erb b/src/zimfw.zsh.erb
index 72ac41a..7d8d619 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.2"
+ @version = "1.3.0-SNAPSHOT"
@ellipsis = " ..."
@okay = "%F{green})%f "
@warn = "! "
diff --git a/zimfw.zsh b/zimfw.zsh
index 2ef4c99..3c57054 100644
--- a/zimfw.zsh
+++ b/zimfw.zsh
@@ -60,12 +60,12 @@ _zimfw_build_init() {
print -R "zimfw() { source ${ZIM_HOME}/zimfw.zsh \"\${@}\" }"
if (( ${#_zfpaths} )) print -R 'fpath=('${_zfpaths:A}' ${fpath})'
if (( ${#_zfunctions} )) print -R 'autoload -Uz '${_zfunctions}
- print -Rn ${(F):-source ${^_zscripts:A}}
+ print -R ${(F)_zcmds}
) ${ztarget}
}
_zimfw_build_login_init() {
- local -Ur zscriptdirs=(${ZIM_HOME} ${${_zscripts%%${ZIM_HOME}/*}:h})
+ local -Ur zscriptdirs=('${ZIM_HOME}' ${${_zdirs%%${ZIM_HOME}/*}:A})
local -r zscriptglob=("${^zscriptdirs[@]}/(^*test*/)#*.zsh(|-theme)(N-.)")
local -r ztarget=${ZIM_HOME}/login_init.zsh
_zimfw_mv =(
@@ -125,6 +125,9 @@ Initialization options:
%B-s%b|%B--source%b Source specified file. The file path is relative to the module root
directory. Default: the file with largest size matching
%B{init.zsh,module_name.{zsh,plugin.zsh,zsh-theme,sh}}%b, if any exist.
+ %B-c%b|%B--cmd%b Execute specified command. Occurrences of the %B{}%b placeholder in the
+ command are subsituted by the module root directory path.
+ %B-s 'script.zsh'%b and %B-c 'source {}/script.zsh'%b are equivalent.
%B-d%b|%B--disabled%b Don't initialize or uninstall the module.
"
if [[ ${${funcfiletrace[1]%:*}:t} != .zimrc ]]; then
@@ -140,7 +143,7 @@ Initialization options:
local zmodule=${1:t} zurl=${1}
local ztype=branch zrev=master
local -i zdisabled=0 zfrozen=0
- local -a zfpaths zfunctions zscripts
+ local -a zfpaths zfunctions zcmds
local zarg zdir
if [[ ${zurl} =~ ^[^:/]+: ]]; then
zmodule=${zmodule%.git}
@@ -203,7 +206,11 @@ Initialization options:
shift
zarg=${1}
if [[ ${zarg} != /* ]] zarg=${zdir}/${zarg}
- zscripts+=(${zarg})
+ zcmds+=("source ${zarg:A}")
+ ;;
+ -c|--cmd)
+ shift
+ zcmds+=(${1//{}/${zdir:A}})
;;
-d|--disabled) zdisabled=1 ;;
*)
@@ -233,16 +240,18 @@ Initialization options:
# prompt_*_setup functions are autoloaded by promptinit
zfunctions+=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t))
fi
- if (( ! ${#zscripts} )); then
- zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
+ if (( ! ${#zcmds} )); then
+ local -r zscript=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
+ zcmds+=("source ${^zscript[@]:A}")
fi
- if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zscripts} )); then
+ if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
print -u2 -PR "%F{yellow}! ${funcfiletrace[1]}:%B${zmodule}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f"$'\n\n'${zusage}
fi
+ _zmodules+=(${zmodule})
+ _zdirs+=(${zdir})
_zfpaths+=(${zfpaths})
_zfunctions+=(${zfunctions})
- _zscripts+=(${zscripts})
- _zmodules+=(${zmodule})
+ _zcmds+=(${zcmds})
fi
fi
}
@@ -303,7 +312,7 @@ _zimfw_compile() {
}
_zimfw_info() {
- print -R 'zimfw version: '${_zversion}' (previous commit is 99e6b31)'
+ print -R 'zimfw version: '${_zversion}' (previous commit is 1fd8961)'
print -R 'ZIM_HOME: '${ZIM_HOME}
print -R 'Zsh version: '${ZSH_VERSION}
print -R 'System info: '$(command uname -a)
@@ -347,7 +356,7 @@ _zimfw_upgrade() {
}
zimfw() {
- local -r _zversion='1.2.2'
+ local -r _zversion='1.3.0-SNAPSHOT'
local -r zusage="Usage: %B${0}%b [%B-q%b|%B-v%b]
Actions:
@@ -369,7 +378,7 @@ Options:
%B-v%b Verbose
"
local ztool
- local -a _zdisableds _zmodules _zfpaths _zfunctions _zscripts _zmodules_zargs
+ local -a _zdisableds _zmodules _zdirs _zfpaths _zfunctions _zcmds _zmodules_zargs
local -i _zprintlevel=1
if (( # > 2 )); then
print -u2 -PR "%F{red}${0}: Too many options%f"$'\n\n'${zusage}