diff --git a/vendor/cmder.sh b/vendor/cmder.sh index dfbf91c71..37f6d336d 100644 --- a/vendor/cmder.sh +++ b/vendor/cmder.sh @@ -49,6 +49,16 @@ if [[ ! "$PATH" =~ "${GIT_INSTALL_ROOT}/bin:" ]] ; then PATH="${GIT_INSTALL_ROOT}/bin:$PATH" fi +if [ "$PROCESSOR_ARCHITECTURE" == "x86" ] && [ "$GIT_INSTALL_ROOT/mingw32" ] ; then + git_mingw_bin="$GIT_INSTALL_ROOT/mingw32/bin" +elif [ "$PROCESSOR_ARCHITECTURE" == "AMD64" ] && [ -d "$GIT_INSTALL_ROOT/mingw64" ] ; then + git_mingw_bin="$GIT_INSTALL_ROOT/mingw64/bin" +fi + +if [[ ! "$PATH" =~ "${git_mingw_bin}:" ]] ; then + PATH="${git_mingw_bin}:$PATH" +fi + PATH="${CMDER_ROOT}/bin:${CMDER_ROOT}/vendor/bin:$PATH:${CMDER_ROOT}" export PATH diff --git a/vendor/init.bat b/vendor/init.bat index 3a622c963..465ab3e86 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,16 @@ 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" +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 ) @@ -238,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\) @@ -345,28 +345,15 @@ if %nix_tools% equ 1 ( ) %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" ( - 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 "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" ) + +%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%" :SET_ENV @@ -421,12 +408,13 @@ 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 ( +:: The CMDER_USER_BIN variable is set in the launcher. +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 +548,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 +557,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/profile.ps1 b/vendor/profile.ps1 index 19eef8b4e..971bd5e8f 100644 --- a/vendor/profile.ps1 +++ b/vendor/profile.ps1 @@ -292,4 +292,6 @@ $CMDER_INIT_END = Get-Date $ElapsedTime = New-TimeSpan -Start $CMDER_INIT_START -End $CMDER_INIT_END +$env:Path = $env:Path -replace ';;', ';' + Write-Verbose "Elapsed Time: $($ElapsedTime.TotalSeconds) seconds total" diff --git a/vendor/user_init.cmd.template b/vendor/user_init.cmd.template index 82fc90b87..797d6ce89 100644 --- a/vendor/user_init.cmd.template +++ b/vendor/user_init.cmd.template @@ -69,41 +69,30 @@ goto :SKIP_CLINK 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%" - ) - ) + + :: TODO: Support for ARM + 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%" + set "path=%CMDER_ROOT%\vendor\bin;%path%" :USER_CONFIG_START @@ -112,40 +101,40 @@ goto :SKIP_CLINK ) 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%" + set "path=%CMDER_USER_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:;;=;% + + set "path=%path:;;=;%" :CMDER_CONFIGURED if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1 - + set CMDER_INIT_END=%time% - + 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%" ) @@ -168,7 +157,7 @@ goto :SKIP_CLINK set time_init= set verbose_output= set user_aliases= + set "PATH=%PATH:;;=;%" exit /b -