mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 09:49:12 +08:00
add prompt for vanilla cmd.exe when clink not present
This commit is contained in:
parent
7c309c6a7b
commit
e3d9f81e25
38
vendor/init.bat
vendored
38
vendor/init.bat
vendored
@ -46,9 +46,9 @@ if "%CMDER_ROOT:~-1%" == "\" SET "CMDER_ROOT=%CMDER_ROOT:~0,-1%"
|
||||
|
||||
:: Include Cmder libraries
|
||||
call "%cmder_root%\vendor\bin\cexec.cmd" /setpath
|
||||
call "%cmder_root%\vendor\lib\lib_console"
|
||||
call "%cmder_root%\vendor\lib\lib_base"
|
||||
call "%cmder_root%\vendor\lib\lib_path"
|
||||
call "%cmder_root%\vendor\lib\lib_console"
|
||||
call "%cmder_root%\vendor\lib\lib_git"
|
||||
call "%cmder_root%\vendor\lib\lib_profile"
|
||||
|
||||
@ -89,7 +89,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
|
||||
set "GIT_INSTALL_ROOT=%~2"
|
||||
shift
|
||||
) else (
|
||||
%print_error% "The Git install root folder "%~2", you specified does not exist!"
|
||||
%print_error% "The Git install root folder "%~2" that you specified does not exist!"
|
||||
exit /b
|
||||
)
|
||||
) else if /i "%1" == "/nix_tools" (
|
||||
@ -111,7 +111,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
|
||||
set "HOME=%~2"
|
||||
shift
|
||||
) else (
|
||||
%print_error% The home folder "%2", you specified does not exist!
|
||||
%print_error% The home folder "%2" that you specified does not exist!
|
||||
exit /b
|
||||
)
|
||||
) else if /i "%1" == "/svn_ssh" (
|
||||
@ -124,6 +124,13 @@ call "%cmder_root%\vendor\lib\lib_profile"
|
||||
goto :var_loop
|
||||
|
||||
:start
|
||||
:: Enable console related methods if verbose/debug is turned on
|
||||
if %debug_output% gtr 0 (set print_debug=%lib_console% debug_output)
|
||||
if %verbose_output% gtr 0 (
|
||||
set print_verbose=%lib_console% verbose_output
|
||||
set print_warning=%lib_console% show_warning
|
||||
)
|
||||
|
||||
:: Sets CMDER_SHELL, CMDER_CLINK, CMDER_ALIASES variables
|
||||
%lib_base% cmder_shell
|
||||
%print_debug% init.bat "Env Var - CMDER_ROOT=%CMDER_ROOT%"
|
||||
@ -140,13 +147,22 @@ if defined CMDER_USER_CONFIG (
|
||||
set CMDER_CONFIG_DIR=%CMDER_USER_CONFIG%
|
||||
)
|
||||
|
||||
if not "%CMDER_SHELL%" == "cmd" (
|
||||
%print_warning% "Incompatible 'ComSpec/Shell' Detetected: %CMDER_SHELL%"
|
||||
set CMDER_CLINK=0
|
||||
set CMDER_ALIASES=0
|
||||
)
|
||||
|
||||
:: Pick right version of Clink
|
||||
if "%PROCESSOR_ARCHITECTURE%"=="x86" (
|
||||
set clink_architecture=x86
|
||||
set architecture_bits=32
|
||||
) else (
|
||||
) else if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
|
||||
set clink_architecture=x64
|
||||
set architecture_bits=64
|
||||
) else (
|
||||
%print_warning% "Incompatible Processor Detetected: %PROCESSOR_ARCHITECTURE%"
|
||||
set CMDER_CLINK=0
|
||||
)
|
||||
|
||||
if "%CMDER_CLINK%" == "1" (
|
||||
@ -182,10 +198,18 @@ if "%CMDER_CLINK%" == "1" (
|
||||
"%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_CONFIG_DIR%" --scripts "%CMDER_ROOT%\vendor"
|
||||
|
||||
if errorlevel 1 (
|
||||
%print_error% "Failed to initialize Clink with error code: %errorlevel%"
|
||||
%print_error% "Clink initilization has failed with error code: %errorlevel%"
|
||||
)
|
||||
) else (
|
||||
%print_verbose% "WARNING: Incompatible 'ComSpec/Shell' Detetected, Skipping Clink Injection!"
|
||||
%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
|
||||
)
|
||||
|
||||
if "%CMDER_CONFIGURED%" GTR "1" (
|
||||
@ -265,7 +289,7 @@ goto :CONFIGURE_GIT
|
||||
:: Add git to the path
|
||||
if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" %lib_path% enhance_path "%GIT_INSTALL_ROOT%\cmd" ""
|
||||
|
||||
:: Add the unix commands at the end to not shadow windows commands like more and find
|
||||
:: 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"
|
||||
|
4
vendor/lib/lib_base.cmd
vendored
4
vendor/lib/lib_base.cmd
vendored
@ -68,13 +68,9 @@ exit /b
|
||||
set CMDER_SHELL=%~n1
|
||||
if not defined CMDER_CLINK (
|
||||
set CMDER_CLINK=1
|
||||
if "%CMDER_SHELL%" equ "tcc" set CMDER_CLINK=0
|
||||
if "%CMDER_SHELL%" equ "tccle" set CMDER_CLINK=0
|
||||
)
|
||||
if not defined CMDER_ALIASES (
|
||||
set CMDER_ALIASES=1
|
||||
if "%CMDER_SHELL%" equ "tcc" set CMDER_ALIASES=0
|
||||
if "%CMDER_SHELL%" equ "tccle" set CMDER_ALIASES=0
|
||||
)
|
||||
exit /b
|
||||
|
||||
|
24
vendor/lib/lib_console.cmd
vendored
24
vendor/lib/lib_console.cmd
vendored
@ -7,9 +7,10 @@ set ESC=
|
||||
:: Much faster than using "%lib_console% debug_output ..." etc.
|
||||
set print_debug=if %debug_output% gtr 0 %lib_console% debug_output
|
||||
set print_verbose=if %verbose_output% gtr 0 %lib_console% verbose_output
|
||||
set print_warning=if %verbose_output% gtr 0 %lib_console% show_warning
|
||||
set print_error=%lib_console% show_error
|
||||
|
||||
if "%fast_init%" == "1" exit /b
|
||||
if %fast_init% gtr %verbose_output% if %fast_init% gtr %debug_output% exit /b
|
||||
|
||||
if "%~1" == "/h" (
|
||||
%lib_base% help "%~0"
|
||||
@ -83,3 +84,24 @@ exit /b
|
||||
|
||||
echo %ESC%[91;1mERROR:%ESC%[0m %~1
|
||||
exit /b
|
||||
|
||||
:show_warning
|
||||
:::===============================================================================
|
||||
:::show_warning - Output a warning message to the console.
|
||||
:::.
|
||||
:::include:
|
||||
:::.
|
||||
::: call "$0"
|
||||
:::.
|
||||
:::usage:
|
||||
:::.
|
||||
::: %lib_console% show_warning "[message]"
|
||||
:::.
|
||||
:::required:
|
||||
:::.
|
||||
::: [message] <in> Message text to display.
|
||||
:::.
|
||||
:::-------------------------------------------------------------------------------
|
||||
|
||||
echo %ESC%[93;1mWARNING:%ESC%[0m %~1
|
||||
exit /b
|
||||
|
8
vendor/lib/lib_git.cmd
vendored
8
vendor/lib/lib_git.cmd
vendored
@ -101,9 +101,9 @@ exit /b
|
||||
|
||||
REM endlocal & set "%~1_MAJOR=!%~1_MAJOR!" & set "%~1_MINOR=!%~1_MINOR!" & set "%~1_PATCH=!%~1_PATCH!" & set "%~1_BUILD=!%~1_BUILD!"
|
||||
if "%~1" == "VENDORED" (
|
||||
endlocal & set "%~1_MAJOR=%VENDORED_MAJOR%" & set "%~1_MINOR=%VENDORED_MINOR%" & set "%~1_PATCH=%VENDORED_PATCH%" & set "%~1_BUILD=%VENDORED_BUILD%"
|
||||
endlocal & set "%~1_MAJOR=%VENDORED_MAJOR%" & set "%~1_MINOR=%VENDORED_MINOR%" & set "%~1_PATCH=%VENDORED_PATCH%" & set "%~1_BUILD=%VENDORED_BUILD%"
|
||||
) else (
|
||||
endlocal & set "%~1_MAJOR=%USER_MAJOR%" & set "%~1_MINOR=%USER_MINOR%" & set "%~1_PATCH=%USER_PATCH%" & set "%~1_BUILD=%USER_BUILD%"
|
||||
endlocal & set "%~1_MAJOR=%USER_MAJOR%" & set "%~1_MINOR=%USER_MINOR%" & set "%~1_PATCH=%USER_PATCH%" & set "%~1_BUILD=%USER_BUILD%"
|
||||
)
|
||||
|
||||
exit /b
|
||||
@ -136,9 +136,9 @@ exit /b
|
||||
:: ... and maybe display it, for debugging purposes.
|
||||
REM %print_debug% :validate_version "Found Git Version for %~1: !%~1_MAJOR!.!%~1_MINOR!.!%~1_PATCH!.!%~1_BUILD!"
|
||||
if "%~1" == "VENDORED" (
|
||||
%print_debug% :validate_version "Found Git Version for %~1: %VENDORED_MAJOR%.%VENDORED_MINOR%.%VENDORED_PATCH%.%VENDORED_BUILD%"
|
||||
%print_debug% :validate_version "Found Git Version for %~1: %VENDORED_MAJOR%.%VENDORED_MINOR%.%VENDORED_PATCH%.%VENDORED_BUILD%"
|
||||
) else (
|
||||
%print_debug% :validate_version "Found Git Version for %~1: %USER_MAJOR%.%USER_MINOR%.%USER_PATCH%.%USER_BUILD%"
|
||||
%print_debug% :validate_version "Found Git Version for %~1: %USER_MAJOR%.%USER_MINOR%.%USER_PATCH%.%USER_BUILD%"
|
||||
)
|
||||
exit /b
|
||||
|
||||
|
60
vendor/lib/lib_path.cmd
vendored
60
vendor/lib/lib_path.cmd
vendored
@ -60,14 +60,14 @@ exit /b
|
||||
)
|
||||
|
||||
if "%fast_init%" == "1" (
|
||||
if "%position%" == "append" (
|
||||
set "PATH=%PATH%;%add_to_path%"
|
||||
) else (
|
||||
set "PATH=%add_to_path%;%PATH%"
|
||||
)
|
||||
goto :end_enhance_path
|
||||
if "%position%" == "append" (
|
||||
set "PATH=%PATH%;%add_to_path%"
|
||||
) else (
|
||||
set "PATH=%add_to_path%;%PATH%"
|
||||
)
|
||||
goto :end_enhance_path
|
||||
) else if "add_to_path" equ "" (
|
||||
goto :end_enhance_path
|
||||
goto :end_enhance_path
|
||||
)
|
||||
|
||||
set found=0
|
||||
@ -78,23 +78,23 @@ exit /b
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
if "!found!" == "0" (
|
||||
echo "!path!"|!WINDIR!\System32\findstr >nul /I /R /C:";!find_query!;"
|
||||
call :set_found
|
||||
echo "!path!"|!WINDIR!\System32\findstr >nul /I /R /C:";!find_query!;"
|
||||
call :set_found
|
||||
)
|
||||
%print_debug% :enhance_path "Env Var INSIDE PATH !find_query! - found=!found!"
|
||||
|
||||
if /i "!position!" == "append" (
|
||||
if "!found!" == "0" (
|
||||
echo "!path!"|!WINDIR!\System32\findstr >nul /I /R /C:";!find_query!\"$"
|
||||
call :set_found
|
||||
)
|
||||
%print_debug% :enhance_path "Env Var END PATH !find_query! - found=!found!"
|
||||
if "!found!" == "0" (
|
||||
echo "!path!"|!WINDIR!\System32\findstr >nul /I /R /C:";!find_query!\"$"
|
||||
call :set_found
|
||||
)
|
||||
%print_debug% :enhance_path "Env Var END PATH !find_query! - found=!found!"
|
||||
) else (
|
||||
if "!found!" == "0" (
|
||||
echo "!path!"|!WINDIR!\System32\findstr >nul /I /R /C:"^\"!find_query!;"
|
||||
call :set_found
|
||||
)
|
||||
%print_debug% :enhance_path "Env Var BEGIN PATH !find_query! - found=!found!"
|
||||
if "!found!" == "0" (
|
||||
echo "!path!"|!WINDIR!\System32\findstr >nul /I /R /C:"^\"!find_query!;"
|
||||
call :set_found
|
||||
)
|
||||
%print_debug% :enhance_path "Env Var BEGIN PATH !find_query! - found=!found!"
|
||||
)
|
||||
endlocal & set found=%found%
|
||||
|
||||
@ -121,24 +121,24 @@ exit /b
|
||||
exit /b
|
||||
|
||||
:toolong
|
||||
echo "%OLD_PATH%">"%temp%\cmder_lib_pathA"
|
||||
echo "%PATH%">"%temp%\cmder_lib_pathB"
|
||||
fc /b "%temp%\cmder_lib_pathA" "%temp%\cmder_lib_pathB" 2>nul 1>nul
|
||||
if errorlevel 1 ( del "%temp%\cmder_lib_pathA" & del "%temp%\cmder_lib_pathB" & goto :changed )
|
||||
del "%temp%\cmder_lib_pathA" & del "%temp%\cmder_lib_pathB"
|
||||
exit /b
|
||||
echo "%OLD_PATH%">"%temp%\cmder_lib_pathA"
|
||||
echo "%PATH%">"%temp%\cmder_lib_pathB"
|
||||
fc /b "%temp%\cmder_lib_pathA" "%temp%\cmder_lib_pathB" 2>nul 1>nul
|
||||
if errorlevel 1 ( del "%temp%\cmder_lib_pathA" & del "%temp%\cmder_lib_pathB" & goto :changed )
|
||||
del "%temp%\cmder_lib_pathA" & del "%temp%\cmder_lib_pathB"
|
||||
exit /b
|
||||
|
||||
:changed
|
||||
%print_debug% :enhance_path "END Env Var - PATH=%path%"
|
||||
%print_debug% :enhance_path "Env Var %find_query% - found=%found%"
|
||||
exit /b
|
||||
%print_debug% :enhance_path "END Env Var - PATH=%path%"
|
||||
%print_debug% :enhance_path "Env Var %find_query% - found=%found%"
|
||||
exit /b
|
||||
|
||||
exit /b
|
||||
|
||||
|
||||
:set_found
|
||||
if "%ERRORLEVEL%" == "0" (
|
||||
set found=1
|
||||
set found=1
|
||||
)
|
||||
|
||||
exit /b
|
||||
@ -202,7 +202,7 @@ exit /b
|
||||
|
||||
set "PATH=%PATH:;;=;%"
|
||||
if "%fast_init%" == "1" (
|
||||
exit /b
|
||||
exit /b
|
||||
)
|
||||
|
||||
%print_debug% :enhance_path_recursive "Env Var - add_path=%add_to_path%"
|
||||
|
20
vendor/lib/lib_profile.cmd
vendored
20
vendor/lib/lib_profile.cmd
vendored
@ -32,15 +32,15 @@ exit /b
|
||||
::: path <out> Sets the path env variable if required.
|
||||
:::-------------------------------------------------------------------------------
|
||||
|
||||
if not exist "%~1" (
|
||||
mkdir "%~1"
|
||||
)
|
||||
if not exist "%~1" (
|
||||
mkdir "%~1"
|
||||
)
|
||||
|
||||
pushd "%~1"
|
||||
for /f "usebackq" %%x in ( `dir /b *.bat *.cmd 2^>nul` ) do (
|
||||
%print_verbose% "Calling '%~1\%%x'..."
|
||||
call "%~1\%%x"
|
||||
)
|
||||
popd
|
||||
exit /b
|
||||
pushd "%~1"
|
||||
for /f "usebackq" %%x in ( `dir /b *.bat *.cmd 2^>nul` ) do (
|
||||
%print_verbose% "Calling '%~1\%%x'..."
|
||||
call "%~1\%%x"
|
||||
)
|
||||
popd
|
||||
exit /b
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user