From 306dffac24627d93228d83956a3d695bfb627751 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 7 Jun 2026 18:06:03 -0400 Subject: [PATCH 1/2] cleanup and fixes --- vendor/init.bat | 55 +++++++++++++++-------------------- vendor/lib/lib_base.cmd | 16 ++++------ vendor/lib/lib_path.cmd | 37 ++++++++++++++++++++++- vendor/user_init.cmd.template | 5 ++-- 4 files changed, 67 insertions(+), 46 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index 3a622c963..2d6505792 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -137,14 +137,14 @@ if %verbose_output% gtr 0 ( %print_debug% init.bat "Env Var - debug_output=%debug_output%" :: Set the Cmder directory paths -set CMDER_CONFIG_DIR=%CMDER_ROOT%\config +set "CMDER_CONFIG_DIR=%CMDER_ROOT%\config" :: Check if we're using Cmder individual user profile if defined CMDER_USER_CONFIG ( %print_debug% init.bat "CMDER IS ALSO USING INDIVIDUAL USER CONFIG FROM '%CMDER_USER_CONFIG%'!" if not exist "%CMDER_USER_CONFIG%\..\opt" md "%CMDER_USER_CONFIG%\..\opt" - set CMDER_CONFIG_DIR=%CMDER_USER_CONFIG% + set "CMDER_CONFIG_DIR=%CMDER_USER_CONFIG%" ) if not "%CMDER_SHELL%" == "cmd" ( @@ -166,16 +166,17 @@ if "%PROCESSOR_ARCHITECTURE%"=="x86" ( set CMDER_CLINK=0 ) -if defined CMDER_USER_CONFIG ( - if exist "%CMDER_ROOT%\config\user_init.cmd" ( - call "%CMDER_ROOT%\config\user_init.cmd" - exit /b - ) else if exist "%CMDER_USER_CONFIG%\config\user_init.cmd" ( - call "%CMDER_USER_CONFIG%\config\user_init.cmd" - exit /b - ) -) else if exist "%CMDER_ROOT%\config\user_init.cmd" ( - call "%CMDER_ROOT%\config\user_init.cmd" +:: Use the generated user init snapshot when present. Shared config keeps precedence. +set "cmder_root_user_init=%CMDER_ROOT%\config\user_init.cmd" +if defined CMDER_USER_CONFIG set "cmder_user_init=%CMDER_USER_CONFIG%\user_init.cmd" + +if exist "%cmder_root_user_init%" ( + call "%cmder_root_user_init%" + exit /b +) + +if defined CMDER_USER_CONFIG if exist "%cmder_user_init%" ( + call "%cmder_user_init%" exit /b ) @@ -346,26 +347,15 @@ if %nix_tools% equ 1 ( %print_debug% init.bat "START - nix_tools(%path_position%): Env Var - PATH=%path%" if %nix_tools% geq 1 ( + set "git_mingw_bin=" if exist "%GIT_INSTALL_ROOT%\mingw32" ( - if "%path_position%" == "append" ( - set "path=%path%;%GIT_INSTALL_ROOT%\mingw32\bin" - ) else ( - set "path=%GIT_INSTALL_ROOT%\mingw32\bin;%path%" - ) + set "git_mingw_bin=%GIT_INSTALL_ROOT%\mingw32\bin" ) else if exist "%GIT_INSTALL_ROOT%\mingw64" ( - if "%path_position%" == "append" ( - set "path=%path%;%GIT_INSTALL_ROOT%\mingw64\bin" - ) else ( - set "path=%GIT_INSTALL_ROOT%\mingw64\bin;%path%" - ) - ) - if exist "%GIT_INSTALL_ROOT%\usr\bin" ( - if "%path_position%" == "append" ( - set "path=%path%;%GIT_INSTALL_ROOT%\usr\bin" - ) else ( - set "path=%GIT_INSTALL_ROOT%\usr\bin;%path%" - ) + set "git_mingw_bin=%GIT_INSTALL_ROOT%\mingw64\bin" ) + + %lib_path% add_path_with_position "%git_mingw_bin%" "%path_position%" + %lib_path% add_path_with_position "%GIT_INSTALL_ROOT%\usr\bin" "%path_position%" ) %print_debug% init.bat "END - nix_tools(%path_position%): Env Var - PATH=%path%" @@ -421,12 +411,12 @@ if %max_depth% gtr 1 ( ) %print_debug% init.bat "END - bin(prepend): Env Var - PATH=%path%" -if defined CMDER_USER_BIN if defined CMDER_USER_ROOT ( +if defined CMDER_USER_BIN ( %print_debug% init.bat "START - user_bin(prepend): Env Var - PATH=%path%" if %max_depth% gtr 1 ( %lib_path% enhance_path_recursive "%CMDER_USER_BIN%" 0 %max_depth% ) else ( - set "path=%CMDER_USER_ROOT%\bin;%path%" + set "path=%CMDER_USER_BIN%;%path%" ) %print_debug% init.bat "END - user_bin(prepend): Env Var - PATH=!path!" ) @@ -560,6 +550,8 @@ if not exist "%CMDER_CONFIG_DIR%\user_init.cmd" ( :CLEANUP set architecture_bits= + set cmder_root_user_init= + set cmder_user_init= set CMDER_ALIASES= set CMDER_INIT_END= set CMDER_INIT_START= @@ -567,6 +559,7 @@ if not exist "%CMDER_CONFIG_DIR%\user_init.cmd" ( set CMDER_CLINK= set debug_output= set fast_init= + set git_mingw_bin= set max_depth= set nix_tools= set path_position= diff --git a/vendor/lib/lib_base.cmd b/vendor/lib/lib_base.cmd index 39371c71e..e498aa891 100644 --- a/vendor/lib/lib_base.cmd +++ b/vendor/lib/lib_base.cmd @@ -98,10 +98,9 @@ exit /b :::. ::: This function checks if the user_aliases file contains the marker ::: ";= Add aliases below here". If the marker is not found, it creates -::: an initial user_aliases store by copying the default user_aliases file -::: from the CMDER_ROOT directory. If the CMDER_USER_CONFIG environment -::: variable is defined, it creates a backup of the existing user_aliases -::: file before copying the default file. +::: an initial user_aliases store by backing up the existing file to +::: `*.old_format` and then copying the default user_aliases file from +::: the CMDER_ROOT directory. :::. :::include: :::. @@ -116,12 +115,7 @@ exit /b type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul if "%errorlevel%" == "1" ( echo Creating initial user_aliases store in "%user_aliases%"... - if defined CMDER_USER_CONFIG ( - copy "%user_aliases%" "%user_aliases%.old_format" - copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" - ) else ( - copy "%user_aliases%" "%user_aliases%.old_format" - copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" - ) + copy "%user_aliases%" "%user_aliases%.old_format" + copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" ) exit /b diff --git a/vendor/lib/lib_path.cmd b/vendor/lib/lib_path.cmd index 6bebc23cd..d50d45c4e 100644 --- a/vendor/lib/lib_path.cmd +++ b/vendor/lib/lib_path.cmd @@ -149,9 +149,44 @@ exit /b exit /b +:add_path_with_position +:::=============================================================================== +:::add_path_with_position - Add a directory to PATH at the start or end. +::: +:::include: +::: +::: call "lib_path.cmd" +::: +:::usage: +::: +::: %lib_path% add_path_with_position "[dir_path]" [append] +::: +:::required: +::: +::: [dir_path] Fully qualified directory path. Ex: "c:\bin" +::: +:::options: +::: +::: append Append to the path env variable rather than pre-pend. +::: +:::output: +::: +::: path Updates the path env variable when the directory exists. +:::------------------------------------------------------------------------------- + if "%~1" == "" exit /b + if not exist "%~1" exit /b + + if /i "%~2" == "append" ( + set "path=%path%;%~1" + ) else ( + set "path=%~1;%path%" + ) + + exit /b + :set_found if "%ERRORLEVEL%" == "0" ( - set found=1 + set found=1 ) exit /b diff --git a/vendor/user_init.cmd.template b/vendor/user_init.cmd.template index 82fc90b87..8ffaac008 100644 --- a/vendor/user_init.cmd.template +++ b/vendor/user_init.cmd.template @@ -118,7 +118,7 @@ goto :SKIP_CLINK if %max_depth% gtr 1 ( %lib_path% enhance_path_recursive "%CMDER_USER_BIN%" 0 %max_depth% ) else ( - set "path=%CMDER_USER_ROOT%\bin;%path%" + set "path=%CMDER_USER_BIN%;%path%" ) ) endlocal && set "path=%path%" @@ -139,7 +139,7 @@ goto :SKIP_CLINK ) ) - set "path=%path:;;=;% + set "path=%path:;;=;%" :CMDER_CONFIGURED if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 @@ -171,4 +171,3 @@ goto :SKIP_CLINK exit /b - From 0fe684215623dabeb41381a3e197826b8eb1980b Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 7 Jun 2026 18:10:51 -0400 Subject: [PATCH 2/2] x --- vendor/init.bat | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index 2d6505792..54390739a 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -166,7 +166,6 @@ if "%PROCESSOR_ARCHITECTURE%"=="x86" ( set CMDER_CLINK=0 ) -:: Use the generated user init snapshot when present. Shared config keeps precedence. set "cmder_root_user_init=%CMDER_ROOT%\config\user_init.cmd" if defined CMDER_USER_CONFIG set "cmder_user_init=%CMDER_USER_CONFIG%\user_init.cmd" @@ -239,7 +238,7 @@ goto :SKIP_CLINK :: Revert back to plain cmd.exe prompt without clink prompt $E[1;32;49m$P$S$_$E[1;30;49mλ$S$E[0m - + :: Add Windows Terminal shell integration support (OSC 133 sequences) if defined WT_SESSION (prompt $e]133;D$e\$e]133;A$e\$e]9;9;$P$e\%PROMPT%$e]133;B$e\)