From b254bad5de70647920fd2a1bfc58c616c2269526 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 9 Nov 2025 01:39:20 +0000 Subject: [PATCH] Add fallback to detect CMDER_ROOT from script location Co-authored-by: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com> --- vendor/cmder.sh | 6 ++++++ vendor/cmder_exinit | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/vendor/cmder.sh b/vendor/cmder.sh index 06b9262..31eab12 100644 --- a/vendor/cmder.sh +++ b/vendor/cmder.sh @@ -30,9 +30,15 @@ run_profile_d() { # Converts Windows paths to Unix paths if needed # ConEmuDir is set by ConEmu/Cmder environment if [ -z "$CMDER_ROOT" ]; then + # Try to get CMDER_ROOT from ConEmuDir case "$ConEmuDir" in *\\*) CMDER_ROOT=$( cd "$(cygpath -u "$ConEmuDir")/../.." && pwd );; esac + + # If still not set, derive from script location (vendor -> root) + if [ -z "$CMDER_ROOT" ]; then + CMDER_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" + fi else case "$CMDER_ROOT" in *\\*) CMDER_ROOT="$(cygpath -u "$CMDER_ROOT")";; diff --git a/vendor/cmder_exinit b/vendor/cmder_exinit index 823a791..dceb0ee 100644 --- a/vendor/cmder_exinit +++ b/vendor/cmder_exinit @@ -67,6 +67,21 @@ elif [ -n "$CMDER_ROOT" ]; then esac fi +# If CMDER_ROOT is still not set, try to derive from script location +# Note: This only works if cmder_exinit is in its original location (vendor/) +if [ -z "$CMDER_ROOT" ] && [ -f "${BASH_SOURCE[0]}" ]; then + # Check if we're in the vendor directory + script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + if [[ "$script_dir" == */vendor ]] || [[ "$script_dir" == */vendor/* ]]; then + # Extract the Cmder root (parent of vendor) + CMDER_ROOT="$( cd "$script_dir/.." && pwd )" + # Verify this looks like a Cmder installation + if [ ! -d "${CMDER_ROOT}/vendor" ]; then + unset CMDER_ROOT + fi + fi +fi + if [ -n "$CMDER_ROOT" ]; then # Remove any trailing '/' from CMDER_ROOT CMDER_ROOT="${CMDER_ROOT%/}"