diff --git a/bin/autoload-zshlib b/bin/autoload-zshlib new file mode 100755 index 0000000..336b533 --- /dev/null +++ b/bin/autoload-zshlib @@ -0,0 +1,15 @@ +#!/usr/bin/env zsh +# vi: set ft=zsh tw=80 ts=2 + +function autoloadZshlib() { + for fp in $fpath; do + if [[ ${fp:t} == 'zshlib.zwc' ]]; then + autoload -w $fp + break + fi + done +} + +if [[ "${ZSH_EVAL_CONTEXT}" == *file ]]; then + autoloadZshlib "$@" +fi diff --git a/bin/azw b/bin/azw index c705bb8..7aca63a 100755 --- a/bin/azw +++ b/bin/azw @@ -1,6 +1,5 @@ #!/usr/bin/env zsh # vi: set ft=zsh tw=80 ts=2 -autoload -w zshlib function buildExternCommandName() { cmdName="azw-$1" @@ -33,5 +32,6 @@ function dispatchCommand() { if [[ "${ZSH_EVAL_CONTEXT}" == toplevel || "${ZSH_EVAL_CONTEXT}" == cmdarg ]]; then _DIR="${0:A:h}" + source autoload-zshlib dispatchCommand "$@" fi diff --git a/bin/azw-ensure-single-fv-user b/bin/azw-ensure-single-fv-user index 9526b85..a3631a6 100755 --- a/bin/azw-ensure-single-fv-user +++ b/bin/azw-ensure-single-fv-user @@ -31,6 +31,6 @@ function main { if [[ "${ZSH_EVAL_CONTEXT}" == toplevel || "${ZSH_EVAL_CONTEXT}" == cmdarg ]]; then _DIR="${0:A:h}" - autoload -w zshlib + source autoload-zshlib main "$@" fi diff --git a/bin/azw-install-default-mas-apps b/bin/azw-install-default-mas-apps index 3166d7a..8a9df3f 100755 --- a/bin/azw-install-default-mas-apps +++ b/bin/azw-install-default-mas-apps @@ -25,6 +25,6 @@ function main() { } if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then - autoload -w zshlib + source autoload-zshlib main "$@" fi