diff --git a/docs/lib/_loader.md b/docs/lib/_loader.md index a817818..67798d8 100644 --- a/docs/lib/_loader.md +++ b/docs/lib/_loader.md @@ -3,6 +3,9 @@ Helper to bootstrap libraries. This file sources all library files so functions will be defined and available. Basically, you need to source this file in any script where you want to use library functions. +Also, you can extend this loader to load your local library files too! +Create your loader script that sources the local libraries and just point `ES_SHELL_LOADER_LOCAL` environment variable to it (e.g. `ES_SHELL_LOADER_LOCAL=$HOME/.local/lib/myloader.sh`), and they will be sourced. + **Usage in scripts** ```bash diff --git a/lib/_loader.sh b/lib/_loader.sh index a53555a..87b4cee 100644 --- a/lib/_loader.sh +++ b/lib/_loader.sh @@ -22,3 +22,8 @@ base_dir=$(cd "$(dirname "${path_self}")" >/dev/null 2>&1 && pwd) . "${base_dir}/ssh.sh" . "${base_dir}/text.sh" . "${base_dir}/ui.sh" + +if [[ -r "${ES_SHELL_LOADER_LOCAL:-}" ]]; then + # shellcheck disable=SC1090 + . "${ES_SHELL_LOADER_LOCAL}" +fi