Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 24 additions & 32 deletions vendor/init.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand All @@ -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
)

Expand Down Expand Up @@ -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\)

Expand Down Expand Up @@ -346,26 +346,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%"

Expand Down Expand Up @@ -421,12 +410,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!"
)
Expand Down Expand Up @@ -560,13 +549,16 @@ 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=
set CMDER_USER_FLAGS=
set CMDER_CLINK=
set debug_output=
set fast_init=
set git_mingw_bin=
set max_depth=
set nix_tools=
set path_position=
Expand Down
16 changes: 5 additions & 11 deletions vendor/lib/lib_base.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
:::.
Expand All @@ -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
37 changes: 36 additions & 1 deletion vendor/lib/lib_path.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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] <in> Fully qualified directory path. Ex: "c:\bin"
:::
:::options:
:::
::: append <in> Append to the path env variable rather than pre-pend.
:::
:::output:
:::
::: path <out> 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
Expand Down
5 changes: 2 additions & 3 deletions vendor/user_init.cmd.template
Original file line number Diff line number Diff line change
Expand Up @@ -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%"
Expand All @@ -139,7 +139,7 @@ goto :SKIP_CLINK
)
)

set "path=%path:;;=;%
set "path=%path:;;=;%"

:CMDER_CONFIGURED
if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1
Expand Down Expand Up @@ -171,4 +171,3 @@ goto :SKIP_CLINK

exit /b


Loading