From 274cce1f0085c812ac46d0aac34b312d156182e9 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 10 Feb 2023 19:19:50 -0800 Subject: [PATCH 01/23] optimize for speed --- vendor/init.bat | 42 +++++++++++++++++++++++++++++++---------- vendor/lib/lib_path.cmd | 38 ++++++++++++++++++++++++------------- 2 files changed, 57 insertions(+), 23 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index 027f710..d9a7bf9 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -306,7 +306,9 @@ goto :CONFIGURE_GIT :CONFIGURE_GIT %print_debug% init.bat "Using Git from '%GIT_INSTALL_ROOT%..." :: Add git to the path -if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" %lib_path% enhance_path "%GIT_INSTALL_ROOT%\cmd" "" +if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" ( + set "path=%GIT_INSTALL_ROOT%\cmd;%path%" +) :: Add the unix commands at the end to not shadow windows commands like `more` and `find` if %nix_tools% equ 1 ( @@ -319,12 +321,24 @@ if %nix_tools% equ 1 ( if %nix_tools% geq 1 ( if exist "%GIT_INSTALL_ROOT%\mingw32" ( - %lib_path% enhance_path "%GIT_INSTALL_ROOT%\mingw32\bin" %path_position% + if "%path_position%" == "append" ( + set "path=%path%;%GIT_INSTALL_ROOT%\mingw32\bin" + ) else ( + set "path=%GIT_INSTALL_ROOT%\mingw32\bin;%path%" + ) ) else if exist "%GIT_INSTALL_ROOT%\mingw64" ( - %lib_path% enhance_path "%GIT_INSTALL_ROOT%\mingw64\bin" %path_position% + 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" ( - %lib_path% enhance_path "%GIT_INSTALL_ROOT%\usr\bin" %path_position% + if "%path_position%" == "append" ( + set "path=%path%;%GIT_INSTALL_ROOT%\usr\bin" + ) else ( + set "path=%GIT_INSTALL_ROOT%\usr\bin;%path%" + ) ) ) @@ -368,14 +382,23 @@ goto :PATH_ENHANCE endlocal :PATH_ENHANCE -%lib_path% enhance_path "%CMDER_ROOT%\vendor\bin" +set "path=%CMDER_ROOT%\vendor\bin;%path%" :USER_CONFIG_START -%lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" 0 %max_depth% -if defined CMDER_USER_BIN ( - %lib_path% enhance_path_recursive "%CMDER_USER_BIN%" 0 %max_depth% +if %max_depth% gtr 1 ( + %lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" 0 %max_depth% +) else ( + set "path=%CMDER_ROOT%\bin;%path%" ) -%lib_path% enhance_path "%CMDER_ROOT%" append + +if defined CMDER_USER_BIN ( + 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=%path%;%CMDER_ROOT%" :: Drop *.bat and *.cmd files into "%CMDER_ROOT%\config\profile.d" :: to run them at startup. @@ -489,7 +512,6 @@ if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 set CMDER_INIT_END=%time% -if %time_init% gtr 0 ( "%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" ) exit /b diff --git a/vendor/lib/lib_path.cmd b/vendor/lib/lib_path.cmd index d9f229b..7cfcaa7 100644 --- a/vendor/lib/lib_path.cmd +++ b/vendor/lib/lib_path.cmd @@ -144,8 +144,12 @@ exit /b exit /b :enhance_path_recursive + call :set_path_recursive "%~1" "%~2" "%~3" + exit /b + +:set_path_recursive :::=============================================================================== -:::enhance_path_recursive - Add a directory and subs to the path env variable if +:::set_path_recursive - Add a directory and subs to the path env variable if ::: required. :::. :::include: @@ -154,7 +158,7 @@ exit /b :::. :::usage: :::. -::: call "%~DP0lib_path" enhance_path_recursive "[dir_path]" [max_depth] [append] +::: call "%~DP0lib_path" set_path_recursive "[dir_path]" [max_depth] [append] :::. :::required: :::. @@ -196,7 +200,11 @@ exit /b if "%fast_init%" == "1" ( if "%add_to_path%" neq "" ( - call :enhance_path "%add_to_path%" %position% + if "%position%" == "append" ( + set "path=%path%;%add_to_path%" + ) else ( + set "path=%add_to_path%;%path%" + ) ) ) @@ -205,15 +213,19 @@ exit /b exit /b ) - %print_debug% :enhance_path_recursive "Env Var - add_path=%add_to_path%" - %print_debug% :enhance_path_recursive "Env Var - position=%position%" - %print_debug% :enhance_path_recursive "Env Var - depth=%depth%" - %print_debug% :enhance_path_recursive "Env Var - max_depth=%max_depth%" + %print_debug% :set_path_recursive "Env Var - add_path=%add_to_path%" + %print_debug% :set_path_recursive "Env Var - position=%position%" + %print_debug% :set_path_recursive "Env Var - depth=%depth%" + %print_debug% :set_path_recursive "Env Var - max_depth=%max_depth%" if %max_depth% gtr %depth% ( if "%add_to_path%" neq "" ( - %print_debug% :enhance_path_recursive "Adding parent directory - '%add_to_path%'" - call :enhance_path "%add_to_path%" %position% + %print_debug% :set_path_recursive "Adding parent directory - '%add_to_path%'" + if "%position%" == "append" ( + set "path=%path%;%add_to_path%" + ) else ( + set "path=%add_to_path%;%path%" + ) ) call :set_depth call :loop_depth @@ -233,10 +245,10 @@ exit /b ) for /d %%i in ("%add_path%\*") do ( - %print_debug% :enhance_path_recursive "Env Var BEFORE - depth=%depth%" - %print_debug% :enhance_path_recursive "Found Subdirectory - '%%~fi'" - call :enhance_path_recursive "%%~fi" %depth% %max_depth% %position% - %print_debug% :enhance_path_recursive "Env Var AFTER- depth=%depth%" + %print_debug% :set_path_recursive "Env Var BEFORE - depth=%depth%" + %print_debug% :set_path_recursive "Found Subdirectory - '%%~fi'" + call :set_path_recursive "%%~fi" %depth% %max_depth% %position% + %print_debug% :set_path_recursive "Env Var AFTER- depth=%depth%" ) exit /b From 56f45a81ca97e32fdd38e12dcf9d3754df0959ff Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 11 Feb 2023 18:57:27 -0800 Subject: [PATCH 02/23] add debugging of path adds --- vendor/init.bat | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index d9a7bf9..51f1eef 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -165,9 +165,22 @@ if "%PROCESSOR_ARCHITECTURE%"=="x86" ( set CMDER_CLINK=0 ) +if exist "%CMDER_ROOT%\config\user_init.cmd" if defined CMDER_USER_CONFIG ( + call "%CMDER_ROOT%\config\user_init.cmd" + + 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" + exit /b +) + if "%CMDER_CLINK%" == "1" ( - REM TODO: If clink is already injected, goto :CLINK_FINISH goto :INJECT_CLINK +) else if "%CMDER_CLINK%" == "2" ( + goto :CLINK_FINISH ) goto :SKIP_CLINK @@ -204,11 +217,15 @@ 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 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 @@ -296,19 +313,22 @@ if exist "%CMDER_ROOT%\vendor\git-for-windows" ( ) :SPECIFIED_GIT -%print_debug% init.bat "Using /GIT_INSTALL_ROOT..." +%print_debug% init.bat "Using specified GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%...." goto :CONFIGURE_GIT :FOUND_GIT -%print_debug% init.bat "Using found Git '%GIT_VERSION_USER%' from '%GIT_INSTALL_ROOT%..." +%print_debug% init.bat "Using found Git '%GIT_VERSION_USER%' from 'v%GIT_INSTALL_ROOT%..." goto :CONFIGURE_GIT :CONFIGURE_GIT %print_debug% init.bat "Using Git from '%GIT_INSTALL_ROOT%..." + :: Add git to the path +%print_debug% init.bat "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.bat "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 ( @@ -319,6 +339,7 @@ if %nix_tools% equ 1 ( set "path_position=" ) +%print_debug% init.bat "START - nix_tools(%path_position%): Env Var - PATH=%path%" if %nix_tools% geq 1 ( if exist "%GIT_INSTALL_ROOT%\mingw32" ( if "%path_position%" == "append" ( @@ -341,6 +362,7 @@ if %nix_tools% geq 1 ( ) ) ) +%print_debug% init.bat "END - nix_tools(%path_position%): Env Var - PATH=%path%" :SET_ENV @@ -373,8 +395,7 @@ if defined git_locale ( ) endlocal && set LANG=%LANG% -%print_debug% init.bat "Env Var - GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%" -%print_debug% init.bat "Found Git in: '%GIT_INSTALL_ROOT%'" +%print_debug% init.bat "Found Git in: 'GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%'" goto :PATH_ENHANCE :NO_GIT @@ -382,23 +403,33 @@ goto :PATH_ENHANCE endlocal :PATH_ENHANCE +%print_debug% init.bat "START - vendor/bin(prepend): Env Var - PATH=%path%" set "path=%CMDER_ROOT%\vendor\bin;%path%" +%print_debug% init.bat "END - vendor/bin(prepend): Env Var - PATH=%path%" :USER_CONFIG_START +%print_debug% init.bat "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.bat "END - bin(prepend): Env Var - PATH=%path%" + 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%" ) + %print_debug% init.bat "END - user_bin(prepend): Env Var - PATH=!path!" ) + +%print_debug% init.bat "START - cmder_root(append): Env Var - PATH=%path%" set "path=%path%;%CMDER_ROOT%" +%print_debug% init.bat "END - cmder_root(append): Env Var - PATH=%path%" :: Drop *.bat and *.cmd files into "%CMDER_ROOT%\config\profile.d" :: to run them at startup. From 7e50f50863f57095266d59dc53253c9f093d1b69 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 11 Feb 2023 18:57:50 -0800 Subject: [PATCH 03/23] add vendor/user_init.optional.cmd --- vendor/user_init.optional.cmd | 160 ++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 vendor/user_init.optional.cmd diff --git a/vendor/user_init.optional.cmd b/vendor/user_init.optional.cmd new file mode 100644 index 0000000..b086da9 --- /dev/null +++ b/vendor/user_init.optional.cmd @@ -0,0 +1,160 @@ +@echo off + +:: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +:: WARNING: THIS IS UNSUPORTED CODE USE IT IF YOU WANT. SEE BELOW FOR DETAILS! +:: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +:: +:: If you use this file you will be using an unsupported option you assume all +:: and responsibility for troubleshooting any issues! +:: +:: ## What is this? +:: +:: This file initializes the Cmder `cmd.exe` shell with hard coded settings so it is much +:: faster at loading the session config since it does not have to auto discover anything. +:: +:: If you want complete control and responsibility of your Cmder setup copy this file to +:: `%CMDER_ROOT%\config\user_init.cmd` and edit to customize your setup your way. +:: +:: ## Shared Cmder Installs +:: +:: If using in a shared Cmder install copy to `%CMDER_ROOT%\config\user_init.cmd` or +:: `%CMDER_USER_ROOT%\config\user_init.cmd` whichever acieves the goal of the shared +:: install. +:: + +if "%CMDER_CLINK%" == "1" ( + goto :INJECT_CLINK +) else if "%CMDER_CLINK%" == "2" ( + goto :CLINK_FINISH +) + +goto :SKIP_CLINK + +:INJECT_CLINK + %print_verbose% "Injecting Clink!" + + :: Check if Clink is not present + if not exist "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" ( + 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 1 ( + %print_error% "Clink initialization has failed with error code: %errorlevel%" + goto :CLINK_FINISH + ) + + set CMDER_CLINK=2 + goto :CLINK_FINISH + +:SKIP_CLINK + %print_warning% "Skipping Clink Injection!" + + for /f "tokens=2 delims=:." %%x in ('chcp') do set cp=%%x + chcp 65001>nul + + :: 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 +:CLINK_FINISH + +if not defined GIT_INSTALL_ROOT set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows" +if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe" +if not defined git_locale set git_locale="%GIT_INSTALL_ROOT%\usr\bin\locale.exe" +if not defined LANG set LANG=en_US.UTF-8 +if not defined user_aliases set "user_aliases=%CMDER_ROOT%\config\user_aliases.cmd" +if not defined aliases set "aliases=%user_aliases%" +if not defined HOME set "HOME=%USERPROFILE%" + +set PLINK_PROTOCOL=ssh + +set "path=%GIT_INSTALL_ROOT%\cmd;%path%" + +set path_position=append +if %nix_tools% equ 1 ( + set "path_position=append" +) else ( + set "path_position=" +) + +if %nix_tools% geq 1 ( + 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%" + ) + ) 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 "path=%CMDER_ROOT%\vendor\bin;%path%" + +:USER_CONFIG_START +if %max_depth% gtr 1 ( + %lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" 0 %max_depth% +) else ( + set "path=%CMDER_ROOT%\bin;%path%" +) + +setlocal enabledelayedexpansion +if defined CMDER_USER_BIN ( + if %max_depth% gtr 1 ( + %lib_path% enhance_path_recursive "%CMDER_USER_BIN%" 0 %max_depth% + ) else ( + set "path=%CMDER_USER_ROOT%\bin;%path%" + ) +) +endlocal && set "path=%path%" + +set "path=%path%;%CMDER_ROOT%" + +call "%user_aliases%" + +%lib_profile% run_profile_d "%CMDER_ROOT%\config\profile.d" +if defined CMDER_USER_CONFIG ( + %lib_profile% run_profile_d "%CMDER_USER_CONFIG%\profile.d" +) + +call "%CMDER_ROOT%\config\user_profile.cmd" +if defined CMDER_USER_CONFIG ( + if exist "%CMDER_USER_CONFIG%\user_profile.cmd" ( + call "%CMDER_USER_CONFIG%\user_profile.cmd" + ) +) + +set "path=%path:;;=;% + +:CMDER_CONFIGURED +if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 + +set CMDER_INIT_END=%time% + +"%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" +exit /b From 727a99b479d57e9125e4c2c816881e9f459994b7 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 11 Feb 2023 19:27:15 -0800 Subject: [PATCH 04/23] shared or user user_init.cmd --- vendor/init.bat | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index 51f1eef..09ff754 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -165,10 +165,10 @@ if "%PROCESSOR_ARCHITECTURE%"=="x86" ( set CMDER_CLINK=0 ) -if exist "%CMDER_ROOT%\config\user_init.cmd" if defined CMDER_USER_CONFIG ( - call "%CMDER_ROOT%\config\user_init.cmd" - - if exist "%CMDER_USER_CONFIG%\config\user_init.cmd" ( +if defined CMDER_USER_CONFIG ( + if exist "%CMDER_ROOT%\config\user_init.cmd" ( + call "%CMDER_ROOT%\config\user_init.cmd" + ) else if exist "%CMDER_USER_CONFIG%\config\user_init.cmd" ( call "%CMDER_USER_CONFIG%\config\user_init.cmd" ) exit /b From 02154a8f8853e7f46e8daddf2e71cff55363a0fd Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 12 Feb 2023 09:46:16 -0800 Subject: [PATCH 05/23] Update to only collext cmder env vars --- vendor/bin/cmder_diag.cmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/bin/cmder_diag.cmd b/vendor/bin/cmder_diag.cmd index f526cff..d806ee6 100644 --- a/vendor/bin/cmder_diag.cmd +++ b/vendor/bin/cmder_diag.cmd @@ -2,9 +2,9 @@ (echo. echo ------------------------------------ -echo set +echo Get Cmder env variables... echo ------------------------------------ -set +set | findstr -i -r "^aliases= architecture_bits ccall= cexec= ^clink_ ^cmder ^debug_output= fast_init= ^GIT_INSTALL_ROOT= ^git_locale= ^HOME= ^max_depth= ^nix_tools= ^path_position= ^path= ^PLINK_PROTOCOL= ^print_ ^SVN_SSH= ^time_init= ^user_aliases= ^verbose_output=" echo. echo ------------------------------------ From 1e623ecab4a1b114c20e04906bfafbfbe9334e8b Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 12 Feb 2023 09:48:27 -0800 Subject: [PATCH 06/23] auto generate cmd user_init.cmd --- vendor/bin/create-cmdercfg.ps1 | 19 ++++ vendor/init.bat | 22 ++++- vendor/psmodules/Cmder.ps1 | 25 +++++ vendor/user_init.cmd.template | 168 +++++++++++++++++++++++++++++++++ 4 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 vendor/bin/create-cmdercfg.ps1 create mode 100644 vendor/user_init.cmd.template diff --git a/vendor/bin/create-cmdercfg.ps1 b/vendor/bin/create-cmdercfg.ps1 new file mode 100644 index 0000000..5fb23a0 --- /dev/null +++ b/vendor/bin/create-cmdercfg.ps1 @@ -0,0 +1,19 @@ +[CmdletBinding()] +param( + [Parameter()] + [string]$shell = 'cmd', + [string]$outfile = "$env:cmder_root\config\user_init.cmd" +) + +$CmderModulePath = Join-path $env:cmder_root "vendor/psmodules/" +$CmderFunctions = Join-Path $CmderModulePath "Cmder.ps1" +. $CmderFunctions + +if ($shell -match 'cmd') { + write-host "Generating Cmder Config for '$shell' shell in '$outfile'..." + templateExpand "$env:cmder_root\vendor\user_init.cmd.template" "$outfile" +} elseif ($shell -match 'powershell') { + write-host "'$shell' is not supported at this time!" +} elseif ($shell -match 'bash') { + write-host "'$shell' is not supported at this time!" +} diff --git a/vendor/init.bat b/vendor/init.bat index 09ff754..d1ca555 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -417,7 +417,7 @@ 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_BIN if defined CMDER_USER_ROOT ( %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% @@ -538,6 +538,26 @@ if "%CMDER_ALIASES%" == "1" if exist "%CMDER_ROOT%\bin\alias.bat" if exist "%CMD set initialConfig= +if defined CMDER_USER_CONFIG ( + if not exist "%CMDER_ROOT%\config\user_init.cmd" if not exist "%CMDER_USER_ROOT%\config\user_init.cmd" ( + powershell -f %cmder_root%\vendor\bin\create-cmdercfg.ps1 -shell cmd -outfile "%CMDER_ROOT%\config\user_init.cmd" + ) + + if not exist "%CMDER_ROOT%\config\user_init.cmd" if not exist "%CMDER_USER_ROOT%\config\user_init.cmd" ( + powershell -f %cmder_root%\vendor\bin\create-cmdercfg.ps1 -shell cmd -outfile "%CMDER_iUSER_ROOT%\config\user_init.cmd" + ) + + if not exist "%CMDER_ROOT%\config\user_init.cmd" if not exist "%CMDER_USER_ROOT%\config\user_init.cmd" ( + %print_error% "Failed to generate Cmder config" + ) +) else if not exist "%CMDER_ROOT%\config\user_init.cmd" ( + powershell -f %cmder_root%\vendor\bin\create-cmdercfg.ps1 -shell cmd -outfile "%CMDER_ROOT%\config\user_init.cmd" + + if not exist "%CMDER_ROOT%\config\user_init.cmd" ( + %print_error% "Failed to generate Cmder config" + ) +) + :CMDER_CONFIGURED if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 diff --git a/vendor/psmodules/Cmder.ps1 b/vendor/psmodules/Cmder.ps1 index a42e40c..ace3679 100644 --- a/vendor/psmodules/Cmder.ps1 +++ b/vendor/psmodules/Cmder.ps1 @@ -176,3 +176,28 @@ function getGitStatusSetting() { return $true } + +function yOrn( $question ) { + Do { + $Answer = Read-Host -Prompt "`n${question}? (y/n) " + } + Until ($Answer -eq 'y' -or $Answer -eq 'n' -or $Answer -eq 'yes' -or $Answer -eq 'no') + + return $Answer +} + +function templateExpand($template, $outfile) { + $template = Get-Content $template -Raw + $expanded = Invoke-Expression "@`"`r`n$template`r`n`"@" + + $overwrite = 'y' + if ((test-path "$outfile")) { + $overwrite = yOrn "'$outfile' already exists do you want to overwrite it" + } + + if ($overwrite -match 'y') { + $expanded | out-file -ErrorAction silentlycontinue -encoding ascii "$outfile" + } else { + write-host "Skipping Cmder '$shell' config generation at user request!" + } +} diff --git a/vendor/user_init.cmd.template b/vendor/user_init.cmd.template new file mode 100644 index 0000000..9f19502 --- /dev/null +++ b/vendor/user_init.cmd.template @@ -0,0 +1,168 @@ +@echo off + +:: This file was autogenerated by Cmder init.bat +:: +:: It is yours to edit and will not be touched again by Cmder. +:: +:: If you wish to recreate this file simply rename it and Cmder will re-create it the next time it is run +:: or run the followin command from a Cmder shell: +:: +:: powershell -f %cmder_root%\vendor\bin\create-cmdercfg.ps1 -shell cmd [-outfile "[filename]"] +:: + +if "%CMDER_CLINK%" == "1" ( + goto :INJECT_CLINK +) else if "%CMDER_CLINK%" == "2" ( + goto :CLINK_FINISH +) + +goto :SKIP_CLINK + +:INJECT_CLINK + %print_verbose% "Injecting Clink!" + + :: Check if Clink is not present + if not exist "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" ( + 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 1 ( + %print_error% "Clink initialization has failed with error code: %errorlevel%" + goto :CLINK_FINISH + ) + + set CMDER_CLINK=2 + goto :CLINK_FINISH + +:SKIP_CLINK + %print_warning% "Skipping Clink Injection!" + + for /f "tokens=2 delims=:." %%x in ('chcp') do set cp=%%x + chcp 65001>nul + + :: 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 +: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 +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%" + +set PLINK_PROTOCOL=$env:PLINK_PROTOCOL + +set "path=%GIT_INSTALL_ROOT%\cmd;%path%" + +set path_position=append +if %nix_tools% equ 1 ( + set "path_position=append" +) else ( + set "path_position=" +) + +if %nix_tools% geq 1 ( + 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%" + ) + ) 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 "path=%CMDER_ROOT%\vendor\bin;%path%" + +:USER_CONFIG_START +if %max_depth% gtr 1 ( + %lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" 0 %max_depth% +) else ( + set "path=%CMDER_ROOT%\bin;%path%" +) + +setlocal enabledelayedexpansion +if defined CMDER_USER_BIN ( + if %max_depth% gtr 1 ( + %lib_path% enhance_path_recursive "%CMDER_USER_BIN%" 0 %max_depth% + ) else ( + set "path=%CMDER_USER_ROOT%\bin;%path%" + ) +) +endlocal && set "path=%path%" + +set "path=%path%;%CMDER_ROOT%" + +call "%user_aliases%" + +%lib_profile% run_profile_d "%CMDER_ROOT%\config\profile.d" +if defined CMDER_USER_CONFIG ( + %lib_profile% run_profile_d "%CMDER_USER_CONFIG%\profile.d" +) + +call "%CMDER_ROOT%\config\user_profile.cmd" +if defined CMDER_USER_CONFIG ( + if exist "%CMDER_USER_CONFIG%\user_profile.cmd" ( + call "%CMDER_USER_CONFIG%\user_profile.cmd" + ) +) + +set "path=%path:;;=;% + +:CMDER_CONFIGURED +if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 + +set CMDER_INIT_END=%time% + +if "%CMDER_INIT_END%" neq "" if "%CMDER_INIT_START%" neq "" ( + "%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" +) + +:: Cleanup +set architecture_bits="" +set CMDER_ALIASES="" +set CMDER_INIT_END="" +set CMDER_INIT_START="" +set debug_output="" +set fast_init="" +set max_depth="" +set nix_tools="" +set path_position="" +set print_debug="" +set print_error="" +set print_verbose="" +set print_warning="" +set time_init="" +set verbose_output="" + +exit /b From 3a2e747d22435492c3ffed67ed6c65cf83e82f9e Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 18 Feb 2023 05:40:46 -0800 Subject: [PATCH 07/23] add cleanup of unused env vars --- vendor/bin/timer.cmd | 24 +++++++++++++++++++++++ vendor/init.bat | 25 ++++++++++++++++++++---- vendor/user_init.cmd.template | 36 +++++++++++++++++++---------------- 3 files changed, 65 insertions(+), 20 deletions(-) diff --git a/vendor/bin/timer.cmd b/vendor/bin/timer.cmd index e0b8424..68a5bc3 100644 --- a/vendor/bin/timer.cmd +++ b/vendor/bin/timer.cmd @@ -11,6 +11,7 @@ set /a hours=%end_h%-%start_h% set /a mins=%end_m%-%start_m% set /a secs=%end_s%-%start_s% set /a ms=%end_ms%-%start_ms% + if %ms% lss 0 set /a secs = %secs% - 1 & set /a ms = 100%ms% if %secs% lss 0 set /a mins = %mins% - 1 & set /a secs = 60%secs% if %mins% lss 0 set /a hours = %hours% - 1 & set /a mins = 60%mins% @@ -20,3 +21,26 @@ if 1%ms% lss 100 set ms=0%ms% :: Mission accomplished set /a totalsecs = %hours%*3600 + %mins%*60 + %secs% echo Elapsed Time: %hours%:%mins%:%secs%.%ms% (%totalsecs%.%ms%s total) + +:: cleanup +set start= +set end= +set options= + +set start_h= +set start_m= +set start_s= +set start_ms= + +set end_h= +set end_m= +set end_s= +set end_ms= + +set hours= +set mins= +set secs= +set ms= + +set totalsecs= + diff --git a/vendor/init.bat b/vendor/init.bat index d1ca555..8f459d8 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -559,10 +559,27 @@ if defined CMDER_USER_CONFIG ( ) :CMDER_CONFIGURED -if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 + if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 + set CMDER_INIT_END=%time% + call "%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" -set CMDER_INIT_END=%time% +:: Cleanup +set architecture_bits= +set CMDER_ALIASES= +set CMDER_INIT_END= +set CMDER_INIT_START= +set CMDER_USER_FLAGS= +set debug_output= +set fast_init= +set max_depth= +set nix_tools= +set path_position= +set print_debug= +set print_error= +set print_verbose= +set print_warning= +set time_init= +set verbose_output= +set user_aliases= - "%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" -) exit /b diff --git a/vendor/user_init.cmd.template b/vendor/user_init.cmd.template index 9f19502..eedf299 100644 --- a/vendor/user_init.cmd.template +++ b/vendor/user_init.cmd.template @@ -145,24 +145,28 @@ if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 set CMDER_INIT_END=%time% if "%CMDER_INIT_END%" neq "" if "%CMDER_INIT_START%" neq "" ( - "%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" + call "%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" ) :: Cleanup -set architecture_bits="" -set CMDER_ALIASES="" -set CMDER_INIT_END="" -set CMDER_INIT_START="" -set debug_output="" -set fast_init="" -set max_depth="" -set nix_tools="" -set path_position="" -set print_debug="" -set print_error="" -set print_verbose="" -set print_warning="" -set time_init="" -set verbose_output="" +set architecture_bits= +set CMDER_ALIASES= +set CMDER_INIT_END= +set CMDER_INIT_START= +set CMDER_USER_FLAGS= +set debug_output= +set fast_init= +set max_depth= +set nix_tools= +set path_position= +set print_debug= +set print_error= +set print_verbose= +set print_warning= +set time_init= +set verbose_output= +set user_aliases= exit /b + + From 9cbc1845fb3b165b6e8f9486c52138da4dc53728 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 18 Feb 2023 05:56:09 -0800 Subject: [PATCH 08/23] cleanup --- vendor/init.bat | 41 +++---- vendor/user_init.cmd.template | 196 +++++++++++++++++----------------- 2 files changed, 120 insertions(+), 117 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index 8f459d8..97694e6 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -561,25 +561,28 @@ if defined CMDER_USER_CONFIG ( :CMDER_CONFIGURED if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 set CMDER_INIT_END=%time% - call "%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" -:: Cleanup -set architecture_bits= -set CMDER_ALIASES= -set CMDER_INIT_END= -set CMDER_INIT_START= -set CMDER_USER_FLAGS= -set debug_output= -set fast_init= -set max_depth= -set nix_tools= -set path_position= -set print_debug= -set print_error= -set print_verbose= -set print_warning= -set time_init= -set verbose_output= -set user_aliases= + if "%CMDER_INIT_END%" neq "" if "%CMDER_INIT_START%" neq "" ( + call "%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" + ) + +:CLEANUP + set architecture_bits= + set CMDER_ALIASES= + set CMDER_INIT_END= + set CMDER_INIT_START= + set CMDER_USER_FLAGS= + set debug_output= + set fast_init= + set max_depth= + set nix_tools= + set path_position= + set print_debug= + set print_error= + set print_verbose= + set print_warning= + set time_init= + set verbose_output= + set user_aliases= exit /b diff --git a/vendor/user_init.cmd.template b/vendor/user_init.cmd.template index eedf299..acc36f9 100644 --- a/vendor/user_init.cmd.template +++ b/vendor/user_init.cmd.template @@ -58,114 +58,114 @@ goto :SKIP_CLINK prompt `$E[1;32;49m`$P`$S`$_`$E[1;30;49mλ`$S`$E[0m 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" -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%" - -set PLINK_PROTOCOL=$env:PLINK_PROTOCOL - -set "path=%GIT_INSTALL_ROOT%\cmd;%path%" - -set path_position=append -if %nix_tools% equ 1 ( - set "path_position=append" -) else ( - set "path_position=" -) - -if %nix_tools% geq 1 ( - 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%" - ) - ) 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 "path=%CMDER_ROOT%\vendor\bin;%path%" + 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%" + + set PLINK_PROTOCOL=$env:PLINK_PROTOCOL + + set "path=%GIT_INSTALL_ROOT%\cmd;%path%" + + set path_position=append + if %nix_tools% equ 1 ( + set "path_position=append" + ) else ( + set "path_position=" + ) + + if %nix_tools% geq 1 ( + 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%" + ) + ) 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 "path=%CMDER_ROOT%\vendor\bin;%path%" :USER_CONFIG_START -if %max_depth% gtr 1 ( - %lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" 0 %max_depth% -) else ( - set "path=%CMDER_ROOT%\bin;%path%" -) - -setlocal enabledelayedexpansion -if defined CMDER_USER_BIN ( if %max_depth% gtr 1 ( - %lib_path% enhance_path_recursive "%CMDER_USER_BIN%" 0 %max_depth% + %lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" 0 %max_depth% ) else ( - set "path=%CMDER_USER_ROOT%\bin;%path%" + set "path=%CMDER_ROOT%\bin;%path%" ) -) -endlocal && set "path=%path%" - -set "path=%path%;%CMDER_ROOT%" - -call "%user_aliases%" - -%lib_profile% run_profile_d "%CMDER_ROOT%\config\profile.d" -if defined CMDER_USER_CONFIG ( - %lib_profile% run_profile_d "%CMDER_USER_CONFIG%\profile.d" -) - -call "%CMDER_ROOT%\config\user_profile.cmd" -if defined CMDER_USER_CONFIG ( - if exist "%CMDER_USER_CONFIG%\user_profile.cmd" ( - call "%CMDER_USER_CONFIG%\user_profile.cmd" + + setlocal enabledelayedexpansion + if defined CMDER_USER_BIN ( + 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=%path:;;=;% + endlocal && set "path=%path%" + + set "path=%path%;%CMDER_ROOT%" + + call "%user_aliases%" + + %lib_profile% run_profile_d "%CMDER_ROOT%\config\profile.d" + if defined CMDER_USER_CONFIG ( + %lib_profile% run_profile_d "%CMDER_USER_CONFIG%\profile.d" + ) + + call "%CMDER_ROOT%\config\user_profile.cmd" + if defined CMDER_USER_CONFIG ( + if exist "%CMDER_USER_CONFIG%\user_profile.cmd" ( + call "%CMDER_USER_CONFIG%\user_profile.cmd" + ) + ) + + set "path=%path:;;=;% :CMDER_CONFIGURED -if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 + if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 + + set CMDER_INIT_END=%time% + + if "%CMDER_INIT_END%" neq "" if "%CMDER_INIT_START%" neq "" ( + call "%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" + ) -set CMDER_INIT_END=%time% - -if "%CMDER_INIT_END%" neq "" if "%CMDER_INIT_START%" neq "" ( - call "%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" -) - -:: Cleanup -set architecture_bits= -set CMDER_ALIASES= -set CMDER_INIT_END= -set CMDER_INIT_START= -set CMDER_USER_FLAGS= -set debug_output= -set fast_init= -set max_depth= -set nix_tools= -set path_position= -set print_debug= -set print_error= -set print_verbose= -set print_warning= -set time_init= -set verbose_output= -set user_aliases= +:CLEANUP + set architecture_bits= + set CMDER_ALIASES= + set CMDER_INIT_END= + set CMDER_INIT_START= + set CMDER_USER_FLAGS= + set debug_output= + set fast_init= + set max_depth= + set nix_tools= + set path_position= + set print_debug= + set print_error= + set print_verbose= + set print_warning= + set time_init= + set verbose_output= + set user_aliases= exit /b From 615ba5f81642b70161cb56f2cf055e4f0431c29e Mon Sep 17 00:00:00 2001 From: Dax T Games Date: Sat, 18 Feb 2023 05:57:12 -0800 Subject: [PATCH 09/23] Delete user_init.optional.cmd --- vendor/user_init.optional.cmd | 160 ---------------------------------- 1 file changed, 160 deletions(-) delete mode 100644 vendor/user_init.optional.cmd diff --git a/vendor/user_init.optional.cmd b/vendor/user_init.optional.cmd deleted file mode 100644 index b086da9..0000000 --- a/vendor/user_init.optional.cmd +++ /dev/null @@ -1,160 +0,0 @@ -@echo off - -:: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -:: WARNING: THIS IS UNSUPORTED CODE USE IT IF YOU WANT. SEE BELOW FOR DETAILS! -:: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -:: -:: If you use this file you will be using an unsupported option you assume all -:: and responsibility for troubleshooting any issues! -:: -:: ## What is this? -:: -:: This file initializes the Cmder `cmd.exe` shell with hard coded settings so it is much -:: faster at loading the session config since it does not have to auto discover anything. -:: -:: If you want complete control and responsibility of your Cmder setup copy this file to -:: `%CMDER_ROOT%\config\user_init.cmd` and edit to customize your setup your way. -:: -:: ## Shared Cmder Installs -:: -:: If using in a shared Cmder install copy to `%CMDER_ROOT%\config\user_init.cmd` or -:: `%CMDER_USER_ROOT%\config\user_init.cmd` whichever acieves the goal of the shared -:: install. -:: - -if "%CMDER_CLINK%" == "1" ( - goto :INJECT_CLINK -) else if "%CMDER_CLINK%" == "2" ( - goto :CLINK_FINISH -) - -goto :SKIP_CLINK - -:INJECT_CLINK - %print_verbose% "Injecting Clink!" - - :: Check if Clink is not present - if not exist "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" ( - 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 1 ( - %print_error% "Clink initialization has failed with error code: %errorlevel%" - goto :CLINK_FINISH - ) - - set CMDER_CLINK=2 - goto :CLINK_FINISH - -:SKIP_CLINK - %print_warning% "Skipping Clink Injection!" - - for /f "tokens=2 delims=:." %%x in ('chcp') do set cp=%%x - chcp 65001>nul - - :: 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 -:CLINK_FINISH - -if not defined GIT_INSTALL_ROOT set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows" -if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe" -if not defined git_locale set git_locale="%GIT_INSTALL_ROOT%\usr\bin\locale.exe" -if not defined LANG set LANG=en_US.UTF-8 -if not defined user_aliases set "user_aliases=%CMDER_ROOT%\config\user_aliases.cmd" -if not defined aliases set "aliases=%user_aliases%" -if not defined HOME set "HOME=%USERPROFILE%" - -set PLINK_PROTOCOL=ssh - -set "path=%GIT_INSTALL_ROOT%\cmd;%path%" - -set path_position=append -if %nix_tools% equ 1 ( - set "path_position=append" -) else ( - set "path_position=" -) - -if %nix_tools% geq 1 ( - 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%" - ) - ) 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 "path=%CMDER_ROOT%\vendor\bin;%path%" - -:USER_CONFIG_START -if %max_depth% gtr 1 ( - %lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" 0 %max_depth% -) else ( - set "path=%CMDER_ROOT%\bin;%path%" -) - -setlocal enabledelayedexpansion -if defined CMDER_USER_BIN ( - if %max_depth% gtr 1 ( - %lib_path% enhance_path_recursive "%CMDER_USER_BIN%" 0 %max_depth% - ) else ( - set "path=%CMDER_USER_ROOT%\bin;%path%" - ) -) -endlocal && set "path=%path%" - -set "path=%path%;%CMDER_ROOT%" - -call "%user_aliases%" - -%lib_profile% run_profile_d "%CMDER_ROOT%\config\profile.d" -if defined CMDER_USER_CONFIG ( - %lib_profile% run_profile_d "%CMDER_USER_CONFIG%\profile.d" -) - -call "%CMDER_ROOT%\config\user_profile.cmd" -if defined CMDER_USER_CONFIG ( - if exist "%CMDER_USER_CONFIG%\user_profile.cmd" ( - call "%CMDER_USER_CONFIG%\user_profile.cmd" - ) -) - -set "path=%path:;;=;% - -:CMDER_CONFIGURED -if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 - -set CMDER_INIT_END=%time% - -"%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" -exit /b From f1e2fb569792d0ab70727688c1c91f7e8dfc8b8c Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 26 Feb 2023 18:00:26 -0800 Subject: [PATCH 10/23] prevent timer results every time. --- vendor/bin/create-cmdercfg.ps1 | 2 +- vendor/init.bat | 2 +- vendor/{user_init.cmd.template => user_init.template.cmd} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename vendor/{user_init.cmd.template => user_init.template.cmd} (98%) diff --git a/vendor/bin/create-cmdercfg.ps1 b/vendor/bin/create-cmdercfg.ps1 index 5fb23a0..16c83fa 100644 --- a/vendor/bin/create-cmdercfg.ps1 +++ b/vendor/bin/create-cmdercfg.ps1 @@ -11,7 +11,7 @@ $CmderFunctions = Join-Path $CmderModulePath "Cmder.ps1" if ($shell -match 'cmd') { write-host "Generating Cmder Config for '$shell' shell in '$outfile'..." - templateExpand "$env:cmder_root\vendor\user_init.cmd.template" "$outfile" + templateExpand "$env:cmder_root\vendor\user_init.template.cmd" "$outfile" } elseif ($shell -match 'powershell') { write-host "'$shell' is not supported at this time!" } elseif ($shell -match 'bash') { diff --git a/vendor/init.bat b/vendor/init.bat index 97694e6..88df305 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -562,7 +562,7 @@ if defined CMDER_USER_CONFIG ( if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 set CMDER_INIT_END=%time% - if "%CMDER_INIT_END%" neq "" if "%CMDER_INIT_START%" neq "" ( + if "%time_init%" == "1" if "%CMDER_INIT_END%" neq "" if "%CMDER_INIT_START%" neq "" ( call "%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" ) diff --git a/vendor/user_init.cmd.template b/vendor/user_init.template.cmd similarity index 98% rename from vendor/user_init.cmd.template rename to vendor/user_init.template.cmd index acc36f9..ebfaf85 100644 --- a/vendor/user_init.cmd.template +++ b/vendor/user_init.template.cmd @@ -144,7 +144,7 @@ goto :SKIP_CLINK set CMDER_INIT_END=%time% - if "%CMDER_INIT_END%" neq "" if "%CMDER_INIT_START%" neq "" ( + if "%time_init%" == "1" if "%CMDER_INIT_END%" neq "" if "%CMDER_INIT_START%" neq "" ( call "%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%" ) From e0b694324ca0248bcb6b2035b26390ea242a8b91 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 5 Mar 2023 15:00:11 -0800 Subject: [PATCH 11/23] add bypass --- vendor/init.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/init.bat b/vendor/init.bat index 88df305..ae4e518 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -551,7 +551,7 @@ if defined CMDER_USER_CONFIG ( %print_error% "Failed to generate Cmder config" ) ) else if not exist "%CMDER_ROOT%\config\user_init.cmd" ( - powershell -f %cmder_root%\vendor\bin\create-cmdercfg.ps1 -shell cmd -outfile "%CMDER_ROOT%\config\user_init.cmd" + powershell -executionpolicy bypass -f %cmder_root%\vendor\bin\create-cmdercfg.ps1 -shell cmd -outfile "%CMDER_ROOT%\config\user_init.cmd" if not exist "%CMDER_ROOT%\config\user_init.cmd" ( %print_error% "Failed to generate Cmder config" From c4d93655841773e6d8b34a2dbfbc607c0af09f2f Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 11 Mar 2023 14:59:12 -0800 Subject: [PATCH 12/23] x --- vendor/init.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/vendor/init.bat b/vendor/init.bat index ae4e518..97c1b07 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -572,6 +572,7 @@ if defined CMDER_USER_CONFIG ( set CMDER_INIT_END= set CMDER_INIT_START= set CMDER_USER_FLAGS= + set CMDER_CLINK= set debug_output= set fast_init= set max_depth= From 42568b7316f2e28b5ca4c6518912b5b4edf85bfa Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 12 Mar 2023 13:02:08 -0700 Subject: [PATCH 13/23] Document '--' command line argument --- README.md | 2 +- launcher/src/strings.rc2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 735fd1e..cda18e9 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ The Cmder's user interface is also designed to be more eye pleasing, and you can | `/SINGLE` | Start Cmder in single mode. | | `/START [start_path]` | Folder path to start in. | | `/TASK [task_name]` | Task to start after launch. | -| `/X [ConEmu extras pars]` | Forwards parameters to ConEmu | +| `-- [ConEmu extras pars]` | Forwards ALL remaining parameters to ConEmu. | ## Context Menu Integration diff --git a/launcher/src/strings.rc2 b/launcher/src/strings.rc2 index 0887307..67866de 100644 --- a/launcher/src/strings.rc2 +++ b/launcher/src/strings.rc2 @@ -6,7 +6,7 @@ STRINGTABLE { IDS_TITLE "Cmder Launcher" - IDS_SWITCHES L"Valid options:\n\n /c [CMDER User Root Path]\n /task [ConEmu Task Name]\n /icon [CMDER Icon Path]\n [/start [Start in Path] | [Start in Path]]\n /single\n /m\n /x [ConEmu extra arguments]\n\nor, either:\n /register [USER | ALL]\n /unregister [USER | ALL]" + IDS_SWITCHES L"Valid options:\n\n /c [CMDER User Root Path]\n /task [ConEmu Task Name]\n /icon [CMDER Icon Path]\n [/start [Start in Path] | [Start in Path]]\n /single\n /m\n -- [ConEmu extra arguments]\n\nNote: '-- [...]' must be the last argument!\n\nor, either:\n /register [USER | ALL]\n /unregister [USER | ALL]" } ///////////////////////////////////////////////////////////////////////////// From b2135cd0a93d8c62d20e95ea69748cc5969e34ef Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Tue, 30 May 2023 11:15:04 -0400 Subject: [PATCH 14/23] don't error if vim slias exists --- vendor/profile.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/profile.ps1 b/vendor/profile.ps1 index d1087b1..4123bfd 100644 --- a/vendor/profile.ps1 +++ b/vendor/profile.ps1 @@ -87,7 +87,7 @@ if ($null -ne $ENV:GIT_INSTALL_ROOT) { } if (Get-Command -Name "vim" -ErrorAction SilentlyContinue) { - New-Alias -name "vi" -value vim + New-Alias -name "vi" -value vim -errorAction SilentlyContinue } if (Get-Module PSReadline -ErrorAction "SilentlyContinue") { From 86b9fb25ab6329438c3307f24cd09802d1baf888 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Mon, 5 Jun 2023 13:22:28 -0400 Subject: [PATCH 15/23] Add ability to launch git bash from external Installed git whwen using Cmder - Mini --- vendor/ConEmu.xml.default | 131 +++++++++++++++++++++++--------------- vendor/cmder_exinit | 7 +- vendor/git-prompt.sh | 15 ++++- vendor/start_git_bash.cmd | 47 ++++++++++++++ 4 files changed, 142 insertions(+), 58 deletions(-) create mode 100644 vendor/start_git_bash.cmd diff --git a/vendor/ConEmu.xml.default b/vendor/ConEmu.xml.default index a4e5cc1..47b53d4 100644 --- a/vendor/ConEmu.xml.default +++ b/vendor/ConEmu.xml.default @@ -1,7 +1,7 @@ - + @@ -42,8 +42,8 @@ - - + + @@ -58,7 +58,7 @@ - + @@ -78,7 +78,6 @@ - @@ -113,13 +112,13 @@ - + - + - + @@ -128,8 +127,8 @@ - - + + @@ -166,19 +165,19 @@ - + - + - + - + @@ -413,15 +412,15 @@ - + - + - + @@ -484,12 +483,12 @@ - - + + - - + + @@ -497,8 +496,8 @@ - - + + @@ -507,8 +506,8 @@ - - + + @@ -516,61 +515,78 @@ - - - + + + - + + + + + + + + + + + + + + + + + + + + - - + + - + - - + + - - + - + + - - + - - + + - + - + - @@ -676,7 +692,7 @@ - + @@ -845,13 +861,13 @@ - - + + - + - + @@ -869,10 +885,16 @@ + + + + + + - + @@ -902,6 +924,15 @@ + + + + + + + + + diff --git a/vendor/cmder_exinit b/vendor/cmder_exinit index 4ec3351..6c29dfd 100644 --- a/vendor/cmder_exinit +++ b/vendor/cmder_exinit @@ -34,7 +34,6 @@ function runProfiled { if [ ! "x${profile_d_scripts}" = "x" ] ; then for x in ${profile_d_scripts} ; do - echo Sourcing "${1}/${x}"... . "${1}/${x}" done fi @@ -46,10 +45,8 @@ function runProfiled { # We do this for bash as admin sessions since $CMDER_ROOT is not being set if [ "$CMDER_ROOT" = "" -a "$ConEmuDir" != "" ] ; then - if [ -d "${ConEmuDir}../../vendor" ] ; then + if [ -d "${ConEmuDir}/../../vendor" ] ; then case "$ConEmuDir" in *\\*) CMDER_ROOT=$( cd "$(cygpath -u "$ConEmuDir")/../.." ; pwd );; esac - else - echo "Running in ConEmu without Cmder, skipping Cmder integration." fi elif [ "$CMDER_ROOT" != "" ] ; then case "$CMDER_ROOT" in *\\*) CMDER_ROOT="$(cygpath -u "$CMDER_ROOT")";; esac @@ -59,8 +56,6 @@ if [ ! "$CMDER_ROOT" = "" ] ; then # Remove any trailing '/' CMDER_ROOT=$(echo $CMDER_ROOT | sed 's:/*$::') - echo "Using \"CMDER_ROOT\" at \"${CMDER_ROOT}\"." - export CMDER_ROOT PATH=${CMDER_ROOT}/bin:${CMDER_ROOT}/vendor/bin:$PATH:${CMDER_ROOT} diff --git a/vendor/git-prompt.sh b/vendor/git-prompt.sh index a02af62..189e3dc 100644 --- a/vendor/git-prompt.sh +++ b/vendor/git-prompt.sh @@ -38,7 +38,7 @@ then . ~/.config/git/git-prompt.sh fi else - PS1='\[\033]0;$MSYSTEM:${PWD//[^[:ascii:]]/?}\007\]' # set window title + PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]' # set window title # PS1="$PS1"'\n' # new line PS1="$PS1"'\[\033[32m\]' # change to green PS1="$PS1"'\u@\h ' # user@host @@ -71,4 +71,15 @@ else PS1="$PS1"'λ ' # prompt: always λ fi -MSYS2_PS1="$PS1" # for detection by MSYS2 SDK's bash.basrc \ No newline at end of file +MSYS2_PS1="$PS1" # for detection by MSYS2 SDK's bash.basrc + +# Evaluate all user-specific Bash completion scripts (if any) +if test -z "$WINELOADERNOEXEC" +then + for c in "$HOME"/bash_completion.d/*.bash + do + # Handle absence of any scripts (or the folder) gracefully + test ! -f "$c" || + . "$c" + done +fi diff --git a/vendor/start_git_bash.cmd b/vendor/start_git_bash.cmd new file mode 100644 index 0000000..136feab --- /dev/null +++ b/vendor/start_git_bash.cmd @@ -0,0 +1,47 @@ +@echo off + +if not defined CMDER_ROOT ( + if defined ConEmuDir ( + for /f "delims=" %%i in ("%ConEmuDir%\..\..") do ( + set "CMDER_ROOT=%%~fi" + ) + ) else ( + for /f "delims=" %%i in ("%~dp0\..") do ( + set "CMDER_ROOT=%%~fi" + ) + ) +) + +if defined ConEmuDir ( + set "gitCommand=--command=%ConEmuBaseDirShort%\conemu-msys2-64.exe" +) + +if exist "%CMDER_ROOT%\vendor\git-for-windows" ( + set "PATH=%CMDER_ROOT%\vendor\git-for-windows\usr\bin;%PATH%" + set "gitCmd=%CMDER_ROOT%\vendor\git-for-windows\git-cmd.exe" + set "bashCmd=%CMDER_ROOT%\vendor\git-for-windows\usr\bin\bash.exe" +) else if exist "%ProgramFiles%\git" ( + set "PATH=%ProgramFiles%\git\usr\bin;%PATH%" + set "gitCmd=%ProgramFiles%\git\git-cmd.exe" + set "bashCmd=%ProgramFiles%\git\usr\bin\bash.exe" + if not exist "%ProgramFiles%\git\etc\profile.d\cmder_exinit.sh" ( + echo Run 'mklink "%ProgramFiles%\git\etc\profile.d\cmder_exinit.sh" "%CMDER_ROOT%\vendor\cmder_exinit"' in 'cmd::Cmder as Admin' to use Cmder with external Git Bash + echo. + echo or + echo. + echo Run 'echo "" ^> "%ProgramFiles%\git\etc\profile.d\cmder_exinit.sh"' in 'cmd::Cmder as Admin' to disable this message. + ) +) else if exist "%ProgramFiles(x86)%\git" ( + set "PATH=%ProgramFiles(x86)%\git\usr\bin;%PATH%" + set "gitCmd=%ProgramFiles(x86)%\git\git-cmd.exe" + set "bashCmd=%ProgramFiles(x86)%\git\usr\bin\bash.exe" + if not exist "%ProgramFiles(x86)%\git\etc\profile.d\cmder_exinit.sh" ( + echo Run 'mklink "%ProgramFiles^(x86^)%\git\etc\profile.d\cmder_exinit.sh" "%CMDER_ROOT%\vendor\cmder_exinit"' in 'cmd::Cmder as Admin' to use Cmder with external Git Bash + echo. + echo or + echo. + echo Run 'echo "" ^> "%ProgramFiles^(x86^)%\git\etc\profile.d\cmder_exinit.sh"' in 'cmd::Cmder as Admin' to disable this message. + ) +) + +"%gitCmd%" --no-cd %gitCommand% "%bashCmd%" --login -i From 4bf659833ca8b5c32d6d1303e87fe33d106fcfaa Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Mon, 3 Jul 2023 16:19:07 -0400 Subject: [PATCH 16/23] fix multiuser user_init.cmd creation --- vendor/bin/create-cmdercfg.ps1 | 15 ++++++++++----- vendor/init.bat | 19 ++++--------------- vendor/psmodules/Cmder.ps1 | 5 +++-- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/vendor/bin/create-cmdercfg.ps1 b/vendor/bin/create-cmdercfg.ps1 index 5fb23a0..e909a91 100644 --- a/vendor/bin/create-cmdercfg.ps1 +++ b/vendor/bin/create-cmdercfg.ps1 @@ -2,18 +2,23 @@ param( [Parameter()] [string]$shell = 'cmd', - [string]$outfile = "$env:cmder_root\config\user_init.cmd" + [string]$outfile = "$env:cmder_config_dir\user_init.cmd" ) +if ($shell -match 'powershell') { + write-host "'$shell' is not supported at this time!" + exit 0 +} elseif ($shell -match 'bash') { + write-host "'$shell' is not supported at this time!" + exit 0 +} + $CmderModulePath = Join-path $env:cmder_root "vendor/psmodules/" $CmderFunctions = Join-Path $CmderModulePath "Cmder.ps1" + . $CmderFunctions if ($shell -match 'cmd') { write-host "Generating Cmder Config for '$shell' shell in '$outfile'..." templateExpand "$env:cmder_root\vendor\user_init.cmd.template" "$outfile" -} elseif ($shell -match 'powershell') { - write-host "'$shell' is not supported at this time!" -} elseif ($shell -match 'bash') { - write-host "'$shell' is not supported at this time!" } diff --git a/vendor/init.bat b/vendor/init.bat index 97694e6..80d8169 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -168,10 +168,11 @@ if "%PROCESSOR_ARCHITECTURE%"=="x86" ( 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 ) - exit /b ) else if exist "%CMDER_ROOT%\config\user_init.cmd" ( call "%CMDER_ROOT%\config\user_init.cmd" exit /b @@ -538,20 +539,8 @@ if "%CMDER_ALIASES%" == "1" if exist "%CMDER_ROOT%\bin\alias.bat" if exist "%CMD set initialConfig= -if defined CMDER_USER_CONFIG ( - if not exist "%CMDER_ROOT%\config\user_init.cmd" if not exist "%CMDER_USER_ROOT%\config\user_init.cmd" ( - powershell -f %cmder_root%\vendor\bin\create-cmdercfg.ps1 -shell cmd -outfile "%CMDER_ROOT%\config\user_init.cmd" - ) - - if not exist "%CMDER_ROOT%\config\user_init.cmd" if not exist "%CMDER_USER_ROOT%\config\user_init.cmd" ( - powershell -f %cmder_root%\vendor\bin\create-cmdercfg.ps1 -shell cmd -outfile "%CMDER_iUSER_ROOT%\config\user_init.cmd" - ) - - if not exist "%CMDER_ROOT%\config\user_init.cmd" if not exist "%CMDER_USER_ROOT%\config\user_init.cmd" ( - %print_error% "Failed to generate Cmder config" - ) -) else if not exist "%CMDER_ROOT%\config\user_init.cmd" ( - powershell -f %cmder_root%\vendor\bin\create-cmdercfg.ps1 -shell cmd -outfile "%CMDER_ROOT%\config\user_init.cmd" +if not exist "%CMDER_CONFIG_DIR%\user_init.cmd" ( + powershell -f "%cmder_root%\vendor\bin\create-cmdercfg.ps1" -shell cmd -outfile "%CMDER_CONFIG_DIR%\user_init.cmd" if not exist "%CMDER_ROOT%\config\user_init.cmd" ( %print_error% "Failed to generate Cmder config" diff --git a/vendor/psmodules/Cmder.ps1 b/vendor/psmodules/Cmder.ps1 index ace3679..79a053f 100644 --- a/vendor/psmodules/Cmder.ps1 +++ b/vendor/psmodules/Cmder.ps1 @@ -186,8 +186,9 @@ function yOrn( $question ) { return $Answer } -function templateExpand($template, $outfile) { - $template = Get-Content $template -Raw +function templateExpand($template_filename, $outfile) { + $template = Get-Content "$template_filename" -Raw + $expanded = Invoke-Expression "@`"`r`n$template`r`n`"@" $overwrite = 'y' From 294f85e33ce749d7b9f04669aa860609da4f6fc4 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Mon, 3 Jul 2023 16:23:45 -0400 Subject: [PATCH 17/23] fixes --- vendor/bin/create-cmdercfg.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vendor/bin/create-cmdercfg.ps1 b/vendor/bin/create-cmdercfg.ps1 index e909a91..05aeaa4 100644 --- a/vendor/bin/create-cmdercfg.ps1 +++ b/vendor/bin/create-cmdercfg.ps1 @@ -11,6 +11,8 @@ if ($shell -match 'powershell') { } elseif ($shell -match 'bash') { write-host "'$shell' is not supported at this time!" exit 0 +} else { + exit 0 } $CmderModulePath = Join-path $env:cmder_root "vendor/psmodules/" From cd92c9fa74487636187af9cfd34bc99a84583ff0 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Mon, 3 Jul 2023 17:51:02 -0400 Subject: [PATCH 18/23] cleanup --- vendor/init.bat | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index 2bf8839..e391f26 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -220,10 +220,10 @@ 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 - if errorlevel 1 ( - %print_error% "Clink initialization has failed with error code: %errorlevel%" - goto :CLINK_FINISH - ) + REM if errorlevel 1 ( + REM %print_error% "Clink initialization has failed with error code: %errorlevel%" + REM goto :CLINK_FINISH + REM ) set CMDER_CLINK=2 From 3ced7a2a1be06f4ddfdd9f892ca34de1cdf82234 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Tue, 4 Jul 2023 11:07:33 -0400 Subject: [PATCH 19/23] '.gitignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 71475ec..3ca8124 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,10 @@ launcher/src/version.rc2 .vs/* .vscode .idea +.vagrant/ +scripts/packer/iso/*.iso +!scripts/packer/floppy/*.exe +scripts/packer/packer_cache +scripts/packer/output-* +*.box + From 4129084494344be140c13ce8c8e784108f0e3e6b Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sat, 8 Jul 2023 13:09:10 -0700 Subject: [PATCH 20/23] add comment to clink.lua explaining /c [folderpath] --- vendor/clink.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vendor/clink.lua b/vendor/clink.lua index 83ef0c0..b05daad 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -666,6 +666,10 @@ for _,lua_module in ipairs(clink.find_files(completions_dir..'*.lua')) do end end +-- If Cmder is launched with '/c [folderPath]', indicating Cmder is installed globally and +-- each user has a private '[folderPath]\config' folder, Clink won't know about the global +-- '%cmder_root%\config dir, so we need to load scripts from there before . Clink loads lua +-- scripts from the profile directory given to it when it was injected. if clink.get_env('CMDER_USER_CONFIG') then local cmder_config_dir = clink.get_env('CMDER_ROOT')..'/config/' for _,lua_module in ipairs(clink.find_files(cmder_config_dir..'*.lua')) do From 6b330b81f2a7e179f7e2d27870d2a40017b060fd Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 11 Aug 2023 10:44:33 -0400 Subject: [PATCH 21/23] allow launching windows terminal w/cmder from cmder --- vendor/user_init.cmd.template | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vendor/user_init.cmd.template b/vendor/user_init.cmd.template index ebfaf85..82fc90b 100644 --- a/vendor/user_init.cmd.template +++ b/vendor/user_init.cmd.template @@ -12,6 +12,8 @@ if "%CMDER_CLINK%" == "1" ( goto :INJECT_CLINK +) else if "%CMDER_CLINK%" == "2" if defined WT_PROFILE_ID ( + goto :INJECT_CLINK ) else if "%CMDER_CLINK%" == "2" ( goto :CLINK_FINISH ) From 94ea2da567941116f8c2d6f50b51c2d806c9b057 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 22 Sep 2023 17:07:56 -0400 Subject: [PATCH 22/23] make it work with windows terminal --- vendor/start_git_bash.cmd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vendor/start_git_bash.cmd b/vendor/start_git_bash.cmd index 136feab..679c5af 100644 --- a/vendor/start_git_bash.cmd +++ b/vendor/start_git_bash.cmd @@ -44,4 +44,8 @@ if exist "%CMDER_ROOT%\vendor\git-for-windows" ( ) ) -"%gitCmd%" --no-cd %gitCommand% "%bashCmd%" --login -i +if defined ConEmuDir ( + "%gitCmd%" --no-cd %gitCommand% "%bashCmd%" --login -i +) else ( + "%bashCmd%" --login -i +) From 7c04ee9f6a3f3500a9ee87e9bf09d7708bf1240d Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 22 Sep 2023 17:15:23 -0400 Subject: [PATCH 23/23] fixes --- vendor/cmder_exinit | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vendor/cmder_exinit b/vendor/cmder_exinit index 6c29dfd..68022a4 100644 --- a/vendor/cmder_exinit +++ b/vendor/cmder_exinit @@ -26,13 +26,13 @@ function runProfiled { unset profile_d_scripts pushd "${1}" >/dev/null - if [ ! "x${ZSH_VERSION}" = "x" ]; then + if [ -n "${ZSH_VERSION}" ]; then profile_d_scripts=$(ls *.zsh 2>/dev/null) - elif [ ! "x${BASH_VERSION}" = "x" ]; then + elif [ -n "${BASH_VERSION}" ]; then profile_d_scripts=$(ls *.sh 2>/dev/null) fi - if [ ! "x${profile_d_scripts}" = "x" ] ; then + if [ -n "${profile_d_scripts}" ] ; then for x in ${profile_d_scripts} ; do . "${1}/${x}" done @@ -52,7 +52,7 @@ elif [ "$CMDER_ROOT" != "" ] ; then case "$CMDER_ROOT" in *\\*) CMDER_ROOT="$(cygpath -u "$CMDER_ROOT")";; esac fi -if [ ! "$CMDER_ROOT" = "" ] ; then +if [ -n "$CMDER_ROOT" ] ; then # Remove any trailing '/' CMDER_ROOT=$(echo $CMDER_ROOT | sed 's:/*$::')