mirror of
https://github.com/cmderdev/cmder.git
synced 2025-11-09 21:59:08 +08:00
Add fallback to detect CMDER_ROOT from script location
Co-authored-by: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com>
This commit is contained in:
6
vendor/cmder.sh
vendored
6
vendor/cmder.sh
vendored
@@ -30,9 +30,15 @@ run_profile_d() {
|
|||||||
# Converts Windows paths to Unix paths if needed
|
# Converts Windows paths to Unix paths if needed
|
||||||
# ConEmuDir is set by ConEmu/Cmder environment
|
# ConEmuDir is set by ConEmu/Cmder environment
|
||||||
if [ -z "$CMDER_ROOT" ]; then
|
if [ -z "$CMDER_ROOT" ]; then
|
||||||
|
# Try to get CMDER_ROOT from ConEmuDir
|
||||||
case "$ConEmuDir" in
|
case "$ConEmuDir" in
|
||||||
*\\*) CMDER_ROOT=$( cd "$(cygpath -u "$ConEmuDir")/../.." && pwd );;
|
*\\*) CMDER_ROOT=$( cd "$(cygpath -u "$ConEmuDir")/../.." && pwd );;
|
||||||
esac
|
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
|
else
|
||||||
case "$CMDER_ROOT" in
|
case "$CMDER_ROOT" in
|
||||||
*\\*) CMDER_ROOT="$(cygpath -u "$CMDER_ROOT")";;
|
*\\*) CMDER_ROOT="$(cygpath -u "$CMDER_ROOT")";;
|
||||||
|
|||||||
15
vendor/cmder_exinit
vendored
15
vendor/cmder_exinit
vendored
@@ -67,6 +67,21 @@ elif [ -n "$CMDER_ROOT" ]; then
|
|||||||
esac
|
esac
|
||||||
fi
|
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
|
if [ -n "$CMDER_ROOT" ]; then
|
||||||
# Remove any trailing '/' from CMDER_ROOT
|
# Remove any trailing '/' from CMDER_ROOT
|
||||||
CMDER_ROOT="${CMDER_ROOT%/}"
|
CMDER_ROOT="${CMDER_ROOT%/}"
|
||||||
|
|||||||
Reference in New Issue
Block a user