From 1a3b0d9315a89ee63d4834c38540a2b9cabea87d Mon Sep 17 00:00:00 2001 From: "T. R. Bernstein" <137705289+trbernstein@users.noreply.github.com> Date: Tue, 2 Jul 2024 23:49:24 +0200 Subject: [PATCH] Add autoload-zshlib binary --- bin/autoload-zshlib | 15 +++++++++++++++ bin/azw | 2 +- bin/azw-ensure-single-fv-user | 2 +- bin/azw-install-default-mas-apps | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100755 bin/autoload-zshlib 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