feat: split existing stuff into new atructure

This commit is contained in:
Jan-Ole Hübner 2025-04-06 19:09:40 +02:00
parent 38035a3c00
commit 29e363d419
13 changed files with 2178 additions and 0 deletions

View file

@ -0,0 +1,25 @@
function autosource {
local zsh_function_dirs zsh_function_dir
# Check for required argument
if (( $# == 0 )); then
echo "autosource: basename of a file in ZSH_FUNC_PATH required"
echo "autosource: usage: autosource basename [arguments]"
return 1
fi
# Split ZSH_FUNC_PATH into an array
IFS=':' read -rA zsh_function_dirs <<< "${ZSH_FUNC_PATH}"
# Search each dir for a matching .zsh file
for zsh_function_dir in "${zsh_function_dirs[@]}"; do
if [[ -r "${zsh_function_dir}/${1}.zsh" ]]; then
source "${zsh_function_dir}/${1}.zsh" "${@:2}"
return
fi
done
echo "autosource: no ${1} in (${ZSH_FUNC_PATH})"
return 1
}