mirror of
https://github.com/cmderdev/cmder.git
synced 2025-06-15 14:17:50 +08:00
Merge pull request #1871 from daxgames/user_lua
Embed 'alias' functionality into 'vendor\bin' and Load User Lua files
This commit is contained in:
131
vendor/bin/alias.cmd
vendored
Normal file
131
vendor/bin/alias.cmd
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
@echo off
|
||||
|
||||
|
||||
if "%ALIASES%" == "" (
|
||||
set ALIASES="%CMDER_ROOT%\config\user_aliases.cmd"
|
||||
)
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
if "%~1" == "" echo Use /? for help & echo. & goto :p_show
|
||||
|
||||
:: check command usage
|
||||
|
||||
rem #region parseargument
|
||||
goto parseargument
|
||||
|
||||
:do_shift
|
||||
shift
|
||||
|
||||
:parseargument
|
||||
set currentarg=%~1
|
||||
|
||||
if /i "%currentarg%" equ "/f" (
|
||||
set ALIASES=%~2
|
||||
shift
|
||||
goto :do_shift
|
||||
) else if /i "%currentarg%" == "/reload" (
|
||||
goto :p_reload
|
||||
) else if "%currentarg%" equ "/?" (
|
||||
goto :p_help
|
||||
) else if /i "%currentarg%" equ "/d" (
|
||||
if "%~2" neq "" (
|
||||
if "%~3" equ "" (
|
||||
:: /d flag for delete existing alias
|
||||
call :p_del %~2
|
||||
shift
|
||||
goto :eof
|
||||
)
|
||||
)
|
||||
) else if "%currentarg%" neq "" (
|
||||
if "%~2" equ "" (
|
||||
:: Show the specified alias
|
||||
doskey /macros | findstr /b %currentarg%= && exit /b
|
||||
echo insufficient parameters.
|
||||
goto :p_help
|
||||
) else (
|
||||
:: handle quotes within command definition, e.g. quoted long file names
|
||||
set _x=%*
|
||||
)
|
||||
)
|
||||
rem #endregion parseargument
|
||||
|
||||
if "%ALIASES%" neq "%CMDER_ROOT%\config\user_aliases.cmd" (
|
||||
set _x=!_x:/f "%ALIASES%" =!
|
||||
|
||||
if not exist "%ALIASES%" (
|
||||
echo ;= @echo off>"%ALIASES%"
|
||||
echo ;= rem Call DOSKEY and use this file as the macrofile>>"%ALIASES%"
|
||||
echo ;= %%SystemRoot%%\system32\doskey /listsize=1000 /macrofile=%%0%%>>"%ALIASES%"
|
||||
echo ;= rem In batch mode, jump to the end of the file>>"%ALIASES%"
|
||||
echo ;= goto:eof>>"%ALIASES%"
|
||||
echo ;= Add aliases below here>>"%ALIASES%"
|
||||
)
|
||||
)
|
||||
|
||||
:: validate alias
|
||||
for /f "delims== tokens=1,* usebackq" %%G in (`echo "%_x%"`) do (
|
||||
set alias_name=%%G
|
||||
set alias_value=%%H
|
||||
)
|
||||
|
||||
:: leading quotes added while validating
|
||||
set alias_name=%alias_name:~1%
|
||||
|
||||
:: trailing quotes added while validating
|
||||
set alias_value=%alias_value:~0,-1%
|
||||
|
||||
::remove spaces
|
||||
set _temp=%alias_name: =%
|
||||
|
||||
if not ["%_temp%"] == ["%alias_name%"] (
|
||||
echo Your alias name can not contain a space
|
||||
endlocal
|
||||
exit /b
|
||||
)
|
||||
|
||||
:: replace already defined alias
|
||||
findstr /b /v /i "%alias_name%=" "%ALIASES%" >> "%ALIASES%.tmp"
|
||||
echo %alias_name%=%alias_value% >> "%ALIASES%.tmp" && type "%ALIASES%.tmp" > "%ALIASES%" & @del /f /q "%ALIASES%.tmp"
|
||||
doskey /macrofile="%ALIASES%"
|
||||
endlocal
|
||||
exit /b
|
||||
|
||||
:p_del
|
||||
set del_alias=%~1
|
||||
findstr /b /v /i "%del_alias%=" "%ALIASES%" >> "%ALIASES%.tmp"
|
||||
type "%ALIASES%".tmp > "%ALIASES%" & @del /f /q "%ALIASES%.tmp"
|
||||
doskey %del_alias%=
|
||||
doskey /macrofile="%ALIASES%"
|
||||
goto:eof
|
||||
|
||||
:p_reload
|
||||
doskey /macrofile="%ALIASES%"
|
||||
echo Aliases reloaded
|
||||
exit /b
|
||||
|
||||
:p_show
|
||||
doskey /macros|findstr /v /r "^;=" | sort
|
||||
exit /b
|
||||
|
||||
:p_help
|
||||
echo.Usage:
|
||||
echo.
|
||||
echo. alias [options] [alias=full command]
|
||||
echo.
|
||||
echo.Options:
|
||||
echo.
|
||||
echo. /d [alias] Delete an [alias].
|
||||
echo. /f [macrofile] Path to the [macrofile] you want to store the new alias in.
|
||||
echo. Default: %cmder_root%\config\user_aliases.cmd
|
||||
echo. /reload Reload the aliases file. Can be used with /f argument.
|
||||
echo. Default: %cmder_root%\config\user_aliases.cmd
|
||||
echo.
|
||||
echo. If alias is called with no parameters, it will display the list of existing aliases.
|
||||
echo.
|
||||
echo. In the command, you can use the following notations:
|
||||
echo. $* allows the alias to assume all the parameters of the supplied command.
|
||||
echo. $1-$9 Allows you to seperate parameter by number, much like %%1 in batch.
|
||||
echo. $T is the command seperator, allowing you to string several commands together into one alias.
|
||||
echo. For more information, read DOSKEY/?
|
||||
exit /b
|
24
vendor/clink.lua
vendored
24
vendor/clink.lua
vendored
@ -367,3 +367,27 @@ for _,lua_module in ipairs(clink.find_files(completions_dir..'*.lua')) do
|
||||
dofile(filename)
|
||||
end
|
||||
end
|
||||
|
||||
local cmder_config_dir = clink.get_env('CMDER_ROOT')..'/config/'
|
||||
for _,lua_module in ipairs(clink.find_files(cmder_config_dir..'*.lua')) do
|
||||
-- Skip files that starts with _. This could be useful if some files should be ignored
|
||||
if not string.match(lua_module, '^_.*') then
|
||||
local filename = cmder_config_dir..lua_module
|
||||
-- use dofile instead of require because require caches loaded modules
|
||||
-- so config reloading using Alt-Q won't reload updated modules.
|
||||
dofile(filename)
|
||||
end
|
||||
end
|
||||
|
||||
if clink.get_env('CMDER_USER_CONFIG') then
|
||||
local cmder_user_config_dir = clink.get_env('CMDER_USER_CONFIG')..'/'
|
||||
for _,lua_module in ipairs(clink.find_files(cmder_user_config_dir..'*.lua')) do
|
||||
-- Skip files that starts with _. This could be useful if some files should be ignored
|
||||
if not string.match(lua_module, '^_.*') then
|
||||
local filename = cmder_user_config_dir..lua_module
|
||||
-- use dofile instead of require because require caches loaded modules
|
||||
-- so config reloading using Alt-Q won't reload updated modules.
|
||||
dofile(filename)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
157
vendor/init.bat
vendored
157
vendor/init.bat
vendored
@ -7,8 +7,8 @@
|
||||
:: !!! Use "%CMDER_ROOT%\config\user_profile.cmd" to add your own startup commands
|
||||
|
||||
:: Use /v command line arg or set to > 0 for verbose output to aid in debugging.
|
||||
set verbose-output=0
|
||||
set debug-output=0
|
||||
set verbose_output=0
|
||||
set debug_output=0
|
||||
set max_depth=1
|
||||
|
||||
:: Find root dir
|
||||
@ -37,9 +37,9 @@ call "%cmder_root%\vendor\lib\lib_profile"
|
||||
if "%~1" == "" (
|
||||
goto :start
|
||||
) else if /i "%1"=="/v" (
|
||||
set verbose-output=1
|
||||
set verbose_output=1
|
||||
) else if /i "%1"=="/d" (
|
||||
set debug-output=1
|
||||
set debug_output=1
|
||||
) else if /i "%1" == "/max_depth" (
|
||||
if "%~2" geq "1" if "%~2" leq "5" (
|
||||
set "max_depth=%~2"
|
||||
@ -58,7 +58,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
|
||||
)
|
||||
) else if /i "%1" == "/user_aliases" (
|
||||
if exist "%~2" (
|
||||
set "user-aliases=%~2"
|
||||
set "user_aliases=%~2"
|
||||
shift
|
||||
)
|
||||
) else if /i "%1" == "/git_install_root" (
|
||||
@ -85,11 +85,13 @@ call "%cmder_root%\vendor\lib\lib_profile"
|
||||
goto var_loop
|
||||
|
||||
:start
|
||||
%lib_console% debug-output init.bat "Env Var - CMDER_ROOT=%CMDER_ROOT%"
|
||||
%lib_console% debug-output init.bat "Env Var - debug-output=%debug-output%"
|
||||
:: Sets CMDER_SHELL, CMDER_CLINK, CMDER_ALIASES
|
||||
%lib_base% cmder_shell
|
||||
%lib_console% debug_output init.bat "Env Var - CMDER_ROOT=%CMDER_ROOT%"
|
||||
%lib_console% debug_output init.bat "Env Var - debug_output=%debug_output%"
|
||||
|
||||
if defined CMDER_USER_CONFIG (
|
||||
%lib_console% debug-output init.bat "CMDER IS ALSO USING INDIVIDUAL USER CONFIG FROM '%CMDER_USER_CONFIG%'!"
|
||||
%lib_console% debug_output init.bat "CMDER IS ALSO USING INDIVIDUAL USER CONFIG FROM '%CMDER_USER_CONFIG%'!"
|
||||
)
|
||||
|
||||
:: Pick right version of clink
|
||||
@ -101,21 +103,25 @@ if "%PROCESSOR_ARCHITECTURE%"=="x86" (
|
||||
set architecture_bits=64
|
||||
)
|
||||
|
||||
:: Tell the user about the clink config files...
|
||||
if defined "%CMDER_USER_CONFIG%\settings" if not exist "%CMDER_USER_CONFIG%\settings" (
|
||||
echo Generating clink initial settings in "%CMDER_USER_CONFIG%\settings"
|
||||
echo Additional *.lua files in "%CMDER_USER_CONFIG%" are loaded on startup.\
|
||||
if "%CMDER_CLINK%" == "1" (
|
||||
%lib_console% verbose_output "Injecting Clink!"
|
||||
|
||||
} else if not exist "%CMDER_ROOT%\config\settings" (
|
||||
echo Generating clink initial settings in "%CMDER_ROOT%\config\settings"
|
||||
echo Additional *.lua files in "%CMDER_ROOT%\config" are loaded on startup.
|
||||
)
|
||||
|
||||
:: Run clink
|
||||
if defined CMDER_USER_CONFIG (
|
||||
:: Run clink
|
||||
if defined CMDER_USER_CONFIG (
|
||||
if not exist "%CMDER_USER_CONFIG%\settings" (
|
||||
echo Generating clink initial settings in "%CMDER_USER_CONFIG%\settings"
|
||||
echo Additional *.lua files in "%CMDER_USER_CONFIG%" are loaded on startup.\
|
||||
)
|
||||
"%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_USER_CONFIG%" --scripts "%CMDER_ROOT%\vendor"
|
||||
) else (
|
||||
) else (
|
||||
if not exist "%CMDER_ROOT%\config\settings" (
|
||||
echo Generating clink initial settings in "%CMDER_ROOT%\config\settings"
|
||||
echo Additional *.lua files in "%CMDER_ROOT%\config" are loaded on startup.
|
||||
)
|
||||
"%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config" --scripts "%CMDER_ROOT%\vendor"
|
||||
)
|
||||
) else (
|
||||
%lib_console% verbose_output "WARNING: Incompatible 'ComSpec/Shell' Detetected Skipping Clink Injection!"
|
||||
)
|
||||
|
||||
:: Prepare for git-for-windows
|
||||
@ -131,10 +137,10 @@ if not defined TERM set TERM=cygwin
|
||||
:: also check that we have a recent enough version of git by examining the version string
|
||||
setlocal enabledelayedexpansion
|
||||
if defined GIT_INSTALL_ROOT (
|
||||
if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" goto :FOUND_GIT)
|
||||
if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" goto :FOUND_GIT
|
||||
)
|
||||
|
||||
%lib_console% debug-output init.bat "Looking for Git install root..."
|
||||
%lib_console% debug_output init.bat "Looking for Git install root..."
|
||||
|
||||
:: get the version information for vendored git binary
|
||||
%lib_git% read_version VENDORED "%CMDER_ROOT%\vendor\git-for-windows\cmd"
|
||||
@ -165,19 +171,18 @@ for /F "delims=" %%F in ('where git.exe 2^>nul') do (
|
||||
set test_dir=
|
||||
goto :FOUND_GIT
|
||||
) else (
|
||||
call :verbose-output Found old !GIT_VERSION_USER! in "!test_dir!", but not using...
|
||||
call :verbose_output Found old !GIT_VERSION_USER! in "!test_dir!", but not using...
|
||||
set test_dir=
|
||||
)
|
||||
) else (
|
||||
|
||||
:: if the user provided git executable is not found
|
||||
if !errorlevel! equ -255 (
|
||||
call :verbose-output No git at "!git_executable!" found.
|
||||
call :verbose_output No git at "!git_executable!" found.
|
||||
set test_dir=
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
:: our last hope: our own git...
|
||||
@ -203,14 +208,15 @@ if defined GIT_INSTALL_ROOT (
|
||||
|
||||
:: define SVN_SSH so we can use git svn with ssh svn repositories
|
||||
if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe"
|
||||
for /F "delims=" %%F in ('env /usr/bin/locale -uU 2^>nul') do (
|
||||
|
||||
for /F "delims=" %%F in ('env /usr/bin/locale -uU 2') do (
|
||||
set "LANG=%%F"
|
||||
)
|
||||
)
|
||||
|
||||
endlocal & set "PATH=%PATH%" & set "LANG=%LANG%" & set "SVN_SSH=%SVN_SSH%" & set "GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
|
||||
%lib_console% debug-output init.bat "Env Var - GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
|
||||
%lib_console% debug-output init.bat "Found Git in: '%GIT_INSTALL_ROOT%'"
|
||||
%lib_console% debug_output init.bat "Env Var - GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
|
||||
%lib_console% debug_output init.bat "Found Git in: '%GIT_INSTALL_ROOT%'"
|
||||
goto :PATH_ENHANCE
|
||||
|
||||
:NO_GIT
|
||||
@ -218,6 +224,7 @@ goto :PATH_ENHANCE
|
||||
endlocal
|
||||
|
||||
:PATH_ENHANCE
|
||||
%lib_path% enhance_path "%CMDER_ROOT%\vendor\bin"
|
||||
%lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" %max_depth%
|
||||
if defined CMDER_USER_BIN (
|
||||
%lib_path% enhance_path_recursive "%CMDER_USER_BIN%" %max_depth%
|
||||
@ -235,59 +242,63 @@ if defined CMDER_USER_CONFIG (
|
||||
:: 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.example',
|
||||
:: must also be self executing, see '.\user_aliases.cmd.example',
|
||||
:: and be in profile.d folder.
|
||||
if not defined user-aliases (
|
||||
if not defined user_aliases (
|
||||
if defined CMDER_USER_CONFIG (
|
||||
set "user-aliases=%CMDER_USER_CONFIG%\user-aliases.cmd"
|
||||
set "user_aliases=%CMDER_USER_CONFIG%\user_aliases.cmd"
|
||||
) else (
|
||||
set "user-aliases=%CMDER_ROOT%\config\user-aliases.cmd"
|
||||
set "user_aliases=%CMDER_ROOT%\config\user_aliases.cmd"
|
||||
)
|
||||
)
|
||||
|
||||
:: The aliases environment variable is used by alias.bat to id
|
||||
:: the default file to store new aliases in.
|
||||
if not defined aliases (
|
||||
set "aliases=%user-aliases%"
|
||||
)
|
||||
if "%CMDER_ALIASES%" == "1" (
|
||||
REM The aliases environment variable is used by alias.bat to id
|
||||
REM the default file to store new aliases in.
|
||||
if not defined aliases (
|
||||
set "aliases=%user_aliases%"
|
||||
)
|
||||
|
||||
:: Make sure we have a self-extracting user-aliases.cmd file
|
||||
setlocal enabledelayedexpansion
|
||||
if not exist "%user-aliases%" (
|
||||
echo Creating initial user-aliases store in "%user-aliases%"...
|
||||
copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
|
||||
) else (
|
||||
type "%user-aliases%" | 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.example" "%user-aliases%"
|
||||
) else (
|
||||
copy "%user-aliases%" "%user-aliases%.old_format"
|
||||
copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
|
||||
)
|
||||
)
|
||||
)
|
||||
REM Make sure we have a self-extracting user_aliases.cmd file
|
||||
setlocal enabledelayedexpansion
|
||||
if not exist "%user_aliases%" (
|
||||
echo Creating initial user_aliases store in "%user_aliases%"...
|
||||
copy "%CMDER_ROOT%\vendor\user_aliases.cmd.example" "%user_aliases%"
|
||||
) else (
|
||||
type "%user_aliases%" | 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.example" "%user_aliases%"
|
||||
) else (
|
||||
copy "%user_aliases%" "%user_aliases%.old_format"
|
||||
copy "%CMDER_ROOT%\vendor\user_aliases.cmd.example" "%user_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"
|
||||
:: 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"
|
||||
)
|
||||
endlocal
|
||||
)
|
||||
endlocal
|
||||
|
||||
:: Add aliases to the environment
|
||||
call "%user-aliases%"
|
||||
call "%user_aliases%"
|
||||
|
||||
:: See vendor\git-for-windows\README.portable for why we do this
|
||||
:: Basically we need to execute this post-install.bat because we are
|
||||
:: manually extracting the archive rather than executing the 7z sfx
|
||||
if exist "%GIT_INSTALL_ROOT%\post-install.bat" (
|
||||
%lib_console% verbose-output "Running Git for Windows one time Post Install...."
|
||||
%lib_console% verbose_output "Running Git for Windows one time Post Install...."
|
||||
pushd "%GIT_INSTALL_ROOT%\"
|
||||
"%GIT_INSTALL_ROOT%\git-bash.exe" --no-needs-console --hide --no-cd --command=post-install.bat
|
||||
popd
|
||||
@ -295,7 +306,7 @@ if exist "%GIT_INSTALL_ROOT%\post-install.bat" (
|
||||
|
||||
:: Set home path
|
||||
if not defined HOME set "HOME=%USERPROFILE%"
|
||||
%lib_console% debug-output init.bat "Env Var - HOME=%HOME%"
|
||||
%lib_console% debug_output init.bat "Env Var - HOME=%HOME%"
|
||||
|
||||
set "initialConfig=%CMDER_ROOT%\config\user_profile.cmd"
|
||||
if exist "%CMDER_ROOT%\config\user_profile.cmd" (
|
||||
@ -331,5 +342,19 @@ echo @echo off
|
||||
) >"%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=
|
||||
|
||||
exit /b
|
||||
|
31
vendor/lib/lib_base.cmd
vendored
31
vendor/lib/lib_base.cmd
vendored
@ -43,3 +43,34 @@ exit /b
|
||||
|
||||
pause
|
||||
exit /b
|
||||
|
||||
:cmder_shell
|
||||
:::===============================================================================
|
||||
:::show_subs - shows all sub routines in a .bat/.cmd file with documentation
|
||||
:::.
|
||||
:::include:
|
||||
:::.
|
||||
::: call "lib_base.cmd"
|
||||
:::.
|
||||
:::usage:
|
||||
:::.
|
||||
::: %lib_base% cmder_shell
|
||||
:::.
|
||||
:::options:
|
||||
:::.
|
||||
::: file <in> full path to file containing lib_routines to display
|
||||
:::.
|
||||
:::-------------------------------------------------------------------------------
|
||||
echo %comspec% | find /i "\cmd.exe" > nul && set "CMDER_SHELL=cmd"
|
||||
echo %comspec% | find /i "\tcc.exe" > nul && set "CMDER_SHELL=tcc"
|
||||
echo %comspec% | find /i "\tccle" > nul && set "CMDER_SHELL=tccle"
|
||||
|
||||
set CMDER_CLINK=1
|
||||
if "%CMDER_SHELL%" equ "tcc" set CMDER_CLINK=0
|
||||
if "%CMDER_SHELL%" equ "tccle" set CMDER_CLINK=0
|
||||
|
||||
set CMDER_ALIASES=1
|
||||
if "%CMDER_SHELL%" equ "tcc" set CMDER_ALIASES=0
|
||||
if "%CMDER_SHELL%" equ "tccle" set CMDER_ALIASES=0
|
||||
|
||||
exit /b
|
||||
|
18
vendor/lib/lib_console.cmd
vendored
18
vendor/lib/lib_console.cmd
vendored
@ -13,9 +13,9 @@ if "%~1" == "/h" (
|
||||
|
||||
exit /b
|
||||
|
||||
:debug-output
|
||||
:debug_output
|
||||
:::===============================================================================
|
||||
:::debug-output - Output a debug message to the console.
|
||||
:::debug_output - Output a debug message to the console.
|
||||
:::.
|
||||
:::include:
|
||||
:::.
|
||||
@ -23,22 +23,22 @@ exit /b
|
||||
:::.
|
||||
:::usage:
|
||||
:::.
|
||||
::: %lib_console% debug-output [caller] [message]
|
||||
::: %lib_console% debug_output [caller] [message]
|
||||
:::.
|
||||
:::required:
|
||||
:::.
|
||||
::: [caller] <in> Script/sub routine name calling debug-output
|
||||
::: [caller] <in> Script/sub routine name calling debug_output
|
||||
:::.
|
||||
::: [message] <in> Message text to display.
|
||||
:::.
|
||||
:::-------------------------------------------------------------------------------
|
||||
|
||||
if %debug-output% gtr 0 echo DEBUG(%~1): %~2 & echo.
|
||||
if %debug_output% gtr 0 echo DEBUG(%~1): %~2 & echo.
|
||||
exit /b
|
||||
|
||||
:verbose-output
|
||||
:verbose_output
|
||||
:::===============================================================================
|
||||
:::verbose-output - Output a debug message to the console.
|
||||
:::verbose_output - Output a debug message to the console.
|
||||
:::.
|
||||
:::include:
|
||||
:::.
|
||||
@ -46,7 +46,7 @@ exit /b
|
||||
:::.
|
||||
:::usage:
|
||||
:::.
|
||||
::: %lib_console% verbose-output "[message]"
|
||||
::: %lib_console% verbose_output "[message]"
|
||||
:::.
|
||||
:::required:
|
||||
:::.
|
||||
@ -54,7 +54,7 @@ exit /b
|
||||
:::.
|
||||
:::-------------------------------------------------------------------------------
|
||||
|
||||
if %verbose-output% gtr 0 echo %~1
|
||||
if %verbose_output% gtr 0 echo %~1
|
||||
exit /b
|
||||
|
||||
:show_error
|
||||
|
14
vendor/lib/lib_git.cmd
vendored
14
vendor/lib/lib_git.cmd
vendored
@ -42,11 +42,11 @@ exit /b
|
||||
|
||||
:: set the executable path
|
||||
set "git_executable=%~2\git.exe"
|
||||
%lib_console% debug-output :read_version "Env Var - git_executable=%git_executable%"
|
||||
%lib_console% debug_output :read_version "Env Var - git_executable=%git_executable%"
|
||||
|
||||
:: check if the executable actually exists
|
||||
if not exist "%git_executable%" (
|
||||
%lib_console% debug-output :read_version "%git_executable% does not exist."
|
||||
%lib_console% debug_output :read_version "%git_executable% does not exist."
|
||||
exit /b -255
|
||||
)
|
||||
|
||||
@ -54,7 +54,7 @@ exit /b
|
||||
for /F "tokens=1,2,3 usebackq" %%A in (`"%git_executable%" --version 2^>nul`) do (
|
||||
if /i "%%A %%B" == "git version" (
|
||||
set "GIT_VERSION_%~1=%%C"
|
||||
%lib_console% debug-output :read_version "Env Var - GIT_VERSION_%~1=%%C"
|
||||
%lib_console% debug_output :read_version "Env Var - GIT_VERSION_%~1=%%C"
|
||||
) else (
|
||||
%lib_console% show_error "git --version" returned an inproper version string!
|
||||
pause
|
||||
@ -124,7 +124,7 @@ exit /b
|
||||
call :parse_version %~1 %~2
|
||||
|
||||
:: ... and maybe display it, for debugging purposes.
|
||||
%lib_console% debug-output :validate_version "Found Git Version for %~1: !%~1_MAJOR!.!%~1_MINOR!.!%~1_PATCH!.!%~1_BUILD!"
|
||||
%lib_console% debug_output :validate_version "Found Git Version for %~1: !%~1_MAJOR!.!%~1_MINOR!.!%~1_PATCH!.!%~1_BUILD!"
|
||||
exit /b
|
||||
|
||||
:compare_versions
|
||||
@ -148,9 +148,9 @@ exit /b
|
||||
:: checks all major, minor, patch and build variables for the given arguments.
|
||||
:: whichever binary that has the most recent version will be used based on the return code.
|
||||
|
||||
:: %lib_console% debug-output Comparing:
|
||||
:: %lib_console% debug-output %~1: !%~1_MAJOR!.!%~1_MINOR!.!%~1_PATCH!.!%~1_BUILD!
|
||||
:: %lib_console% debug-output %~2: !%~2_MAJOR!.!%~2_MINOR!.!%~2_PATCH!.!%~2_BUILD!
|
||||
:: %lib_console% debug_output Comparing:
|
||||
:: %lib_console% debug_output %~1: !%~1_MAJOR!.!%~1_MINOR!.!%~1_PATCH!.!%~1_BUILD!
|
||||
:: %lib_console% debug_output %~2: !%~2_MAJOR!.!%~2_MINOR!.!%~2_PATCH!.!%~2_BUILD!
|
||||
|
||||
if !%~1_MAJOR! GTR !%~2_MAJOR! (exit /b 1)
|
||||
if !%~1_MAJOR! LSS !%~2_MAJOR! (exit /b -1)
|
||||
|
32
vendor/lib/lib_path.cmd
vendored
32
vendor/lib/lib_path.cmd
vendored
@ -57,28 +57,28 @@ exit /b
|
||||
set "find_query=%find_query: =\ %"
|
||||
set found=0
|
||||
|
||||
%lib_console% debug-output :enhance_path "Env Var - find_query=%find_query%"
|
||||
echo "%PATH%"|findstr >nul /I /R ";%find_query%\"$"
|
||||
%lib_console% debug_output :enhance_path "Env Var - find_query=%find_query%"
|
||||
echo "%path%"|findstr >nul /I /R ";%find_query%\"$"
|
||||
if "!ERRORLEVEL!" == "0" set found=1
|
||||
|
||||
%lib_console% debug-output :enhance_path "Env Var 1 - found=!found!"
|
||||
%lib_console% debug_output :enhance_path "Env Var 1 - found=!found!"
|
||||
if "!found!" == "0" (
|
||||
echo "%PATH%"|findstr >nul /i /r ";%find_query%;"
|
||||
echo "%path%"|findstr >nul /i /r ";%find_query%;"
|
||||
if "!ERRORLEVEL!" == "0" set found=1
|
||||
%lib_console% debug-output :enhance_path "Env Var 2 - found=!found!"
|
||||
%lib_console% debug_output :enhance_path "Env Var 2 - found=!found!"
|
||||
)
|
||||
|
||||
if "%found%" == "0" (
|
||||
%lib_console% debug-output :enhance_path "BEFORE Env Var - PATH=!path!"
|
||||
%lib_console% debug_output :enhance_path "BEFORE Env Var - PATH=!path!"
|
||||
if /i "%position%" == "append" (
|
||||
%lib_console% debug-output :enhance_path "Appending '%add_path%'"
|
||||
%lib_console% debug_output :enhance_path "Appending '%add_path%'"
|
||||
set "PATH=%PATH%;%add_path%"
|
||||
) else (
|
||||
%lib_console% debug-output :enhance_path "Prepending '%add_path%'"
|
||||
%lib_console% debug_output :enhance_path "Prepending '%add_path%'"
|
||||
set "PATH=%add_path%;%PATH%"
|
||||
)
|
||||
|
||||
%lib_console% debug-output :enhance_path "AFTER Env Var - PATH=!path!"
|
||||
%lib_console% debug_output :enhance_path "AFTER Env Var - PATH=!path!"
|
||||
)
|
||||
|
||||
endlocal & set "PATH=%PATH:;;=;%"
|
||||
@ -134,20 +134,20 @@ exit /b
|
||||
|
||||
if "%depth%" == "" set depth=0
|
||||
|
||||
%lib_console% debug-output :enhance_path_recursive "Env Var - add_path=%add_path%"
|
||||
%lib_console% debug-output :enhance_path_recursive "Env Var - position=%position%"
|
||||
%lib_console% debug-output :enhance_path_recursive "Env Var - max_depth=%max_depth%"
|
||||
%lib_console% debug_output :enhance_path_recursive "Env Var - add_path=%add_path%"
|
||||
%lib_console% debug_output :enhance_path_recursive "Env Var - position=%position%"
|
||||
%lib_console% debug_output :enhance_path_recursive "Env Var - max_depth=%max_depth%"
|
||||
|
||||
if %max_depth% gtr !depth! (
|
||||
%lib_console% debug-output :enhance_path_recursive "Adding parent directory - '%add_path%'"
|
||||
%lib_console% debug_output :enhance_path_recursive "Adding parent directory - '%add_path%'"
|
||||
call :enhance_path "%add_path%" %position%
|
||||
set /a "depth=!depth!+1"
|
||||
|
||||
for /d %%i in ("%add_path%\*") do (
|
||||
%lib_console% debug-output :enhance_path_recursive "Env Var BEFORE - depth=!depth!"
|
||||
%lib_console% debug-output :enhance_path_recursive "Found Subdirectory - '%%~fi'"
|
||||
%lib_console% debug_output :enhance_path_recursive "Env Var BEFORE - depth=!depth!"
|
||||
%lib_console% debug_output :enhance_path_recursive "Found Subdirectory - '%%~fi'"
|
||||
call :enhance_path_recursive "%%~fi" %max_depth% %position%
|
||||
%lib_console% debug-output :enhance_path_recursive "Env Var AFTER- depth=!depth!"
|
||||
%lib_console% debug_output :enhance_path_recursive "Env Var AFTER- depth=!depth!"
|
||||
)
|
||||
)
|
||||
|
||||
|
2
vendor/lib/lib_profile.cmd
vendored
2
vendor/lib/lib_profile.cmd
vendored
@ -39,7 +39,7 @@ exit /b
|
||||
|
||||
pushd "%~1"
|
||||
for /f "usebackq" %%x in ( `dir /b *.bat *.cmd 2^>nul` ) do (
|
||||
%lib_console% verbose-output "Calling '%~1\%%x'..."
|
||||
%lib_console% verbose_output "Calling '%~1\%%x'..."
|
||||
call "%~1\%%x"
|
||||
)
|
||||
popd
|
||||
|
Reference in New Issue
Block a user