diff --git a/lib/waldwaechter.sh b/lib/waldwaechter.sh index 76a160c..74cb3d8 100644 --- a/lib/waldwaechter.sh +++ b/lib/waldwaechter.sh @@ -3,7 +3,18 @@ # Source this file to make all AI characters available as commands # Determine the repo root directory (lib/ is inside repo root) -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# Support both bash and zsh +if [[ -n "$BASH_VERSION" ]]; then + # Bash: use BASH_SOURCE + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +elif [[ -n "$ZSH_VERSION" ]]; then + # Zsh: use ${(%):-%x} to get the script path + SCRIPT_DIR="$(cd "$(dirname "${(%):-%x}")" && pwd)" +else + # Fallback: use $0 (may not work when sourced) + SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +fi + WALDWAECHTER_DIR="$(dirname "$SCRIPT_DIR")" ROLES_DIR="${WALDWAECHTER_DIR}/crumbforest_roles"