From f4bb5108abff558aa1cfdc5bd3e71244ed9d5705 Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Tue, 26 May 2026 14:32:06 -0700 Subject: [PATCH] Add SCRIPT_DIR --- install.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e034b22..f744301 100755 --- a/install.sh +++ b/install.sh @@ -10,6 +10,20 @@ HOME=${HOME:-$(cd ~ && pwd)} LOCAL_BIN="${HOME}/.local/bin" STARSHIP_INSTALL_HASH="52c64f14a558034ebeb1907ea9364e802b32474576fd3e68265f73bc33cc8fbb" +# 1. Get the raw script path (handles Bash vs Zsh) +TARGET="${BASH_SOURCE[0]}" + +# 2. Loop to resolve symlinks completely +while [ -L "$TARGET" ]; do + DIR=$(cd -P "$(dirname -- "$TARGET")" &>/dev/null && pwd) + TARGET=$(readlink "$TARGET") + # If $TARGET is a relative symlink, resolve it relative to the symlink's directory + [[ $TARGET != /* ]] && TARGET="$DIR/$TARGET" +done + +# 3. Get the final absolute directory +SCRIPT_DIR="$(cd -P "$(dirname -- "$TARGET")" &>/dev/null && pwd)" + have_command() { command -v "${1}" >/dev/null 2>&1 } @@ -296,7 +310,7 @@ read_saved_prefs # Defaults if not passed in or saved. # TODO: use flags instead of environment variables. -: ${BASEDIR:=$HOME/.skel} +: ${BASEDIR:=${SCRIPT_DIR}} : ${MINIMAL:=0} : ${INSTALL_KEYS:=1} : ${TRUST_ALL_KEYS:=0}