From 6e5b91f8a7dccdafc8eb67421af6b0005244fdb6 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 20 Jun 2026 22:09:32 -0400 Subject: [PATCH 1/5] revert unnecessary changes. --- vendor/init.cmd | 2 +- vendor/user_init.cmd.template | 186 ++++++++-------------------------- 2 files changed, 41 insertions(+), 147 deletions(-) diff --git a/vendor/init.cmd b/vendor/init.cmd index 25502d10f..393aff345 100644 --- a/vendor/init.cmd +++ b/vendor/init.cmd @@ -222,13 +222,13 @@ goto :SKIP_CLINK ) "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_CONFIG_DIR%" --scripts "%CMDER_ROOT%\vendor" - set CMDER_CLINK=2 :: Check if a fatal error occurred when trying to inject Clink if errorlevel 2 ( REM %print_error% "Clink injection has failed with error code: %errorlevel%" goto :SKIP_CLINK ) + set CMDER_CLINK=2 goto :CLINK_FINISH diff --git a/vendor/user_init.cmd.template b/vendor/user_init.cmd.template index 77764203a..bd01f1041 100644 --- a/vendor/user_init.cmd.template +++ b/vendor/user_init.cmd.template @@ -10,6 +10,10 @@ :: powershell -f %cmder_root%\vendor\bin\create-cmdercfg.ps1 -shell cmd [-outfile "[filename]"] :: +if "%CMDER_CONFIGURED%" == "1" ( + goto CMDER_CONFIGURED +) + if "%CMDER_CLINK%" == "1" ( goto :INJECT_CLINK ) else if "%CMDER_CLINK%" == "2" if defined WT_PROFILE_ID ( @@ -25,7 +29,6 @@ goto :SKIP_CLINK :: Check if Clink is not present if not exist "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" ( - %print_error% "Clink executable is not present in 'vendor\clink\clink_%clink_architecture%.exe'" goto :SKIP_CLINK ) @@ -41,24 +44,14 @@ goto :SKIP_CLINK copy "%CMDER_ROOT%\vendor\cmder_prompt_config.lua.default" "%CMDER_CONFIG_DIR%\cmder_prompt_config.lua" ) - :: Cleanup legacy Clink Settings file - if exist "%CMDER_CONFIG_DIR%\settings" if exist "%CMDER_CONFIG_DIR%\clink_settings" ( - del "%CMDER_CONFIG_DIR%\settings" - ) - - :: Cleanup legacy Clink history file - if exist "%CMDER_CONFIG_DIR%\.history" if exist "%CMDER_CONFIG_DIR%\clink_history" ( - del "%CMDER_CONFIG_DIR%\.history" - ) - "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_CONFIG_DIR%" --scripts "%CMDER_ROOT%\vendor" - set CMDER_CLINK=2 - :: Check if a fatal error occurred when trying to inject Clink - if errorlevel 2 ( - goto :SKIP_CLINK + if errorlevel 1 ( + %print_error% "Clink initialization has failed with error code: %errorlevel%" + goto :CLINK_FINISH ) + set CMDER_CLINK=2 goto :CLINK_FINISH :SKIP_CLINK @@ -70,85 +63,66 @@ 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\) - chcp %cp%>nul :CLINK_FINISH + :: 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\) -if "%CMDER_CONFIGURED%" GTR "1" ( - %print_verbose% "Cmder is already configured, skipping Cmder Init!" - - goto :USER_ALIASES -) else if "%CMDER_CONFIGURED%" == "1" ( - %print_verbose% "Cmder is already configured, skipping to Cmder User Init!" + if not defined GIT_INSTALL_ROOT set "GIT_INSTALL_ROOT=$env:GIT_INSTALL_ROOT" + if not defined SVN_SSH set "SVN_SSH=$env:SVN_SSH" + if not defined git_locale set "git_locale=$env:git_locale" + if not defined LANG set "LANG=$env:LANG" + if not defined user_aliases set "user_aliases=$env:user_aliases" + if not defined aliases set "aliases=%user_aliases%" + if not defined HOME set "HOME=%USERPROFILE%" - goto :USER_CONFIG_START -) -if not defined GIT_INSTALL_ROOT set "GIT_INSTALL_ROOT=$env:GIT_INSTALL_ROOT" -if not defined SVN_SSH set "SVN_SSH=$env:SVN_SSH" -if not defined git_locale set "git_locale=$env:git_locale" -if not defined LANG set "LANG=$env:LANG" -if not defined HOME set "HOME=%USERPROFILE%" +:CMDER_CONFIG + set "PLINK_PROTOCOL=$env:PLINK_PROTOCOL" -set "PLINK_PROTOCOL=$env:PLINK_PROTOCOL" + if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" ( + set "path=%GIT_INSTALL_ROOT%\cmd;%path%" + ) -%print_debug% init.cmd "START - git.exe(prepend): Env Var - PATH=%path%" -if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" ( - set "path=%GIT_INSTALL_ROOT%\cmd;%path%" -) -%print_debug% init.cmd "END - git.exe(prepend): Env Var - PATH=%path%" - -:: Add the unix commands at the end to not shadow windows commands like `more` and `find` -if %nix_tools% equ 1 ( - %print_verbose% "Preferring Windows commands" - set "path_position=append" -) else ( - %print_verbose% "Preferring *nix commands" - set "path_position=" -) + :: Add the unix commands at the end to not shadow windows commands like `more` and `find` + set path_position_nix_tools=append + if %nix_tools% equ 2 ( + set "path_position_nix_tools=prepend" + ) -%print_debug% init.cmd "START - nix_tools(%path_position%): Env Var - PATH=%path%" -set "git_mingw_bin=" -if exist "%GIT_INSTALL_ROOT%\mingw32" ( - set "git_mingw_bin=%GIT_INSTALL_ROOT%\mingw32\bin" -) else if exist "%GIT_INSTALL_ROOT%\mingw64" ( - set "git_mingw_bin=%GIT_INSTALL_ROOT%\mingw64\bin" -) + :: TODO: Support for ARM + set "git_mingw_bin=" + if "%PROCESSOR_ARCHITECTURE%" == "x86" if exist "%GIT_INSTALL_ROOT%\mingw32" ( + set "git_mingw_bin=%GIT_INSTALL_ROOT%\mingw32\bin" + ) else if "%PROCESSOR_ARCHITECTURE%" == "AMD64" if exist "%GIT_INSTALL_ROOT%\mingw64" ( + 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.cmd "END - nix_tools(%path_position%): Env Var - PATH=%path%" + %lib_path% add_path_with_position "%git_mingw_bin%" "%path_position_nix_tools%" + %lib_path% add_path_with_position "%GIT_INSTALL_ROOT%\usr\bin" "%path_position_nix_tools%" -%print_debug% init.cmd "START - vendor/bin(prepend): Env Var - PATH=%path%" -set "path=%CMDER_ROOT%\vendor\bin;%path%" -%print_debug% init.cmd "END - vendor/bin(prepend): Env Var - PATH=%path%" + set "path=%CMDER_ROOT%\vendor\bin;%path%" :USER_CONFIG_START - %print_debug% init.cmd "START - bin(prepend): Env Var - PATH=%path%" if %max_depth% gtr 1 ( %lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" 0 %max_depth% ) else ( set "path=%CMDER_ROOT%\bin;%path%" ) - %print_debug% init.cmd "END - bin(prepend): Env Var - PATH=%path%" :: The CMDER_USER_BIN variable is set in the launcher. if defined CMDER_USER_BIN ( - %print_debug% init.cmd "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_BIN%;%path%" ) - %print_debug% init.cmd "END - user_bin(prepend): Env Var - PATH=!path!" ) - %print_debug% init.cmd "START - cmder_root(append): Env Var - PATH=%path%" set "path=%path%;%CMDER_ROOT%" - %print_debug% init.cmd "END - cmder_root(append): Env Var - PATH=%path%" + + call "%user_aliases%" :: Drop *.bat and *.cmd files into "%CMDER_ROOT%\config\profile.d" :: to run them at startup. @@ -157,91 +131,13 @@ set "path=%CMDER_ROOT%\vendor\bin;%path%" %lib_profile% run_profile_d "%CMDER_USER_CONFIG%\profile.d" ) -:USER_ALIASES - :: Allows user to override default aliases store using profile.d - :: scripts run above by setting the 'aliases' env variable. - :: - :: Note: If overriding default aliases store file the aliases - :: must also be self executing, see '.\user_aliases.cmd.default', - :: and be in profile.d folder. - if not defined user_aliases ( - set "user_aliases=%CMDER_CONFIG_DIR%\user_aliases.cmd" - ) - - if "%CMDER_ALIASES%" == "1" ( - REM The aliases environment variable is used by alias.cmd to id - REM the default file to store new aliases in. - if not defined aliases ( - set "aliases=%user_aliases%" - ) - - REM Make sure we have a self-extracting user_aliases.cmd file - if not exist "%user_aliases%" ( - echo Creating initial user_aliases store in "%user_aliases%"... - copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" - ) else ( - %lib_base% update_legacy_aliases - ) - - :: Update old 'user_aliases' to new self executing 'user_aliases.cmd' - if exist "%CMDER_ROOT%\config\aliases" ( - echo Updating old "%CMDER_ROOT%\config\aliases" to new format... - type "%CMDER_ROOT%\config\aliases" >> "%user_aliases%" - del "%CMDER_ROOT%\config\aliases" - ) else if exist "%user_aliases%.old_format" ( - echo Updating old "%user_aliases%" to new format... - type "%user_aliases%.old_format" >> "%user_aliases%" - del "%user_aliases%.old_format" - ) - ) - - :: Add aliases to the environment - type "%user_aliases%" | %WINDIR%\System32\findstr /b /l /i "history=cat " >nul - if "%ERRORLEVEL%" == "0" ( - echo Migrating alias 'history' to new Clink 1.x.x... - call "%CMDER_ROOT%\vendor\bin\alias.cmd" /d history - echo Restart the session to activate changes! - ) - - call "%user_aliases%" - - if "%CMDER_CONFIGURED%" gtr "1" goto :CMDER_CONFIGURED - - set "initialConfig=%CMDER_ROOT%\config\user_profile.cmd" - if exist "%CMDER_ROOT%\config\user_profile.cmd" ( - REM Create this file and place your own command in there - %print_debug% init.cmd "Calling - %CMDER_ROOT%\config\user_profile.cmd" - call "%CMDER_ROOT%\config\user_profile.cmd" - ) - + call "%CMDER_ROOT%\config\user_profile.cmd" if defined CMDER_USER_CONFIG ( - set "initialConfig=%CMDER_USER_CONFIG%\user_profile.cmd" if exist "%CMDER_USER_CONFIG%\user_profile.cmd" ( - REM Create this file and place your own command in there - %print_debug% init.cmd "Calling - %CMDER_USER_CONFIG%\user_profile.cmd" call "%CMDER_USER_CONFIG%\user_profile.cmd" ) ) - if not exist "%initialConfig%" ( - echo Creating user startup file: "%initialConfig%" - copy "%CMDER_ROOT%\vendor\user_profile.cmd.default" "%initialConfig%" - ) - - if "%CMDER_ALIASES%" == "1" if exist "%CMDER_ROOT%\bin\alias.bat" if exist "%CMDER_ROOT%\vendor\bin\alias.cmd" ( - echo Cmder's 'alias' command has been moved into "%CMDER_ROOT%\vendor\bin\alias.cmd" - echo to get rid of this message either: - echo. - echo Delete the file "%CMDER_ROOT%\bin\alias.bat" - echo. - echo or - echo. - echo If you have customized it and want to continue using it instead of the included version - echo * Rename "%CMDER_ROOT%\bin\alias.bat" to "%CMDER_ROOT%\bin\alias.cmd". - echo * Search for 'user-aliases' and replace it with 'user_aliases'. - ) - - set initialConfig= set "path=%path:;;=;%" :CMDER_CONFIGURED @@ -256,14 +152,12 @@ set "path=%CMDER_ROOT%\vendor\bin;%path%" :CLEANUP set architecture_bits= set CMDER_ALIASES= - set CMDER_CLINK= set CMDER_INIT_END= set CMDER_INIT_START= set CMDER_USER_FLAGS= set debug_output= set fast_init= set git_mingw_bin= - set initialConfig= set max_depth= set nix_tools= set path_position= From 197e448e51e5715faa0c0ccac7ea65de9041337f Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 20 Jun 2026 22:24:11 -0400 Subject: [PATCH 2/5] fixes --- vendor/user_init.cmd.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/user_init.cmd.template b/vendor/user_init.cmd.template index bd01f1041..f5a720f5f 100644 --- a/vendor/user_init.cmd.template +++ b/vendor/user_init.cmd.template @@ -46,9 +46,9 @@ goto :SKIP_CLINK "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_CONFIG_DIR%" --scripts "%CMDER_ROOT%\vendor" - if errorlevel 1 ( + if errorlevel 2 ( %print_error% "Clink initialization has failed with error code: %errorlevel%" - goto :CLINK_FINISH + goto :SKIP_CLINK ) set CMDER_CLINK=2 From d2800868d30325437c6f5f25ca174fa15361b4bd Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 20 Jun 2026 22:35:07 -0400 Subject: [PATCH 3/5] cleanup --- vendor/user_init.cmd.template | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/vendor/user_init.cmd.template b/vendor/user_init.cmd.template index f5a720f5f..ec173d4c2 100644 --- a/vendor/user_init.cmd.template +++ b/vendor/user_init.cmd.template @@ -29,21 +29,11 @@ goto :SKIP_CLINK :: Check if Clink is not present if not exist "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" ( + :: this allows the user to install Clink globally and remove it from Cmder if they wish. goto :SKIP_CLINK ) :: Run Clink - if not exist "%CMDER_CONFIG_DIR%\settings" if not exist "%CMDER_CONFIG_DIR%\clink_settings" ( - echo Generating Clink initial settings in "%CMDER_CONFIG_DIR%\clink_settings" - copy "%CMDER_ROOT%\vendor\clink_settings.default" "%CMDER_CONFIG_DIR%\clink_settings" - echo Additional *.lua files in "%CMDER_CONFIG_DIR%" are loaded on startup. - ) - - if not exist "%CMDER_CONFIG_DIR%\cmder_prompt_config.lua" ( - echo Creating Cmder prompt config file: "%CMDER_CONFIG_DIR%\cmder_prompt_config.lua" - copy "%CMDER_ROOT%\vendor\cmder_prompt_config.lua.default" "%CMDER_CONFIG_DIR%\cmder_prompt_config.lua" - ) - "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_CONFIG_DIR%" --scripts "%CMDER_ROOT%\vendor" if errorlevel 2 ( @@ -65,10 +55,10 @@ goto :SKIP_CLINK chcp %cp%>nul -:CLINK_FINISH :: 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\) +:CLINK_FINISH if not defined GIT_INSTALL_ROOT set "GIT_INSTALL_ROOT=$env:GIT_INSTALL_ROOT" if not defined SVN_SSH set "SVN_SSH=$env:SVN_SSH" if not defined git_locale set "git_locale=$env:git_locale" From b675c79165ed24db93d5fddf79aee6e662108f33 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 20 Jun 2026 22:42:17 -0400 Subject: [PATCH 4/5] cleanup --- vendor/user_init.cmd.template | 2 -- 1 file changed, 2 deletions(-) diff --git a/vendor/user_init.cmd.template b/vendor/user_init.cmd.template index ec173d4c2..a5e1bd2e4 100644 --- a/vendor/user_init.cmd.template +++ b/vendor/user_init.cmd.template @@ -67,8 +67,6 @@ goto :SKIP_CLINK if not defined aliases set "aliases=%user_aliases%" if not defined HOME set "HOME=%USERPROFILE%" - -:CMDER_CONFIG set "PLINK_PROTOCOL=$env:PLINK_PROTOCOL" if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" ( From 98cc7195d1cd1ef80e5f2f51f05d256f2d39eadc Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 20 Jun 2026 22:47:32 -0400 Subject: [PATCH 5/5] cleanup --- vendor/user_init.cmd.template | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vendor/user_init.cmd.template b/vendor/user_init.cmd.template index a5e1bd2e4..caf3a61b1 100644 --- a/vendor/user_init.cmd.template +++ b/vendor/user_init.cmd.template @@ -29,7 +29,8 @@ goto :SKIP_CLINK :: Check if Clink is not present if not exist "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" ( - :: this allows the user to install Clink globally and remove it from Cmder if they wish. + :: This allows the user to install Clink globally and remove it from Cmder if they wish. + :: The user may also want to remove parts of the SKIP_CLINK section. goto :SKIP_CLINK ) @@ -53,11 +54,11 @@ 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 - chcp %cp%>nul - :: 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\) + chcp %cp%>nul + :CLINK_FINISH if not defined GIT_INSTALL_ROOT set "GIT_INSTALL_ROOT=$env:GIT_INSTALL_ROOT" if not defined SVN_SSH set "SVN_SSH=$env:SVN_SSH"