Skip to content

Commit b254bad

Browse files
CopilotDRSDavidSoft
andcommitted
Add fallback to detect CMDER_ROOT from script location
Co-authored-by: DRSDavidSoft <[email protected]>
1 parent 49b7eee commit b254bad

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

vendor/cmder.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,15 @@ run_profile_d() {
3030
# Converts Windows paths to Unix paths if needed
3131
# ConEmuDir is set by ConEmu/Cmder environment
3232
if [ -z "$CMDER_ROOT" ]; then
33+
# Try to get CMDER_ROOT from ConEmuDir
3334
case "$ConEmuDir" in
3435
*\\*) CMDER_ROOT=$( cd "$(cygpath -u "$ConEmuDir")/../.." && pwd );;
3536
esac
37+
38+
# If still not set, derive from script location (vendor -> root)
39+
if [ -z "$CMDER_ROOT" ]; then
40+
CMDER_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
41+
fi
3642
else
3743
case "$CMDER_ROOT" in
3844
*\\*) CMDER_ROOT="$(cygpath -u "$CMDER_ROOT")";;

vendor/cmder_exinit

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,21 @@ elif [ -n "$CMDER_ROOT" ]; then
6767
esac
6868
fi
6969

70+
# If CMDER_ROOT is still not set, try to derive from script location
71+
# Note: This only works if cmder_exinit is in its original location (vendor/)
72+
if [ -z "$CMDER_ROOT" ] && [ -f "${BASH_SOURCE[0]}" ]; then
73+
# Check if we're in the vendor directory
74+
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
75+
if [[ "$script_dir" == */vendor ]] || [[ "$script_dir" == */vendor/* ]]; then
76+
# Extract the Cmder root (parent of vendor)
77+
CMDER_ROOT="$( cd "$script_dir/.." && pwd )"
78+
# Verify this looks like a Cmder installation
79+
if [ ! -d "${CMDER_ROOT}/vendor" ]; then
80+
unset CMDER_ROOT
81+
fi
82+
fi
83+
fi
84+
7085
if [ -n "$CMDER_ROOT" ]; then
7186
# Remove any trailing '/' from CMDER_ROOT
7287
CMDER_ROOT="${CMDER_ROOT%/}"

0 commit comments

Comments
 (0)