mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-11 00:39:08 +08:00
commit
ae2fda72fd
56
vendor/clink.lua
vendored
56
vendor/clink.lua
vendored
@ -222,6 +222,21 @@ local function get_git_status()
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Gets the conflict status
|
||||||
|
-- @return {bool} indicating true for conflict, false for no conflicts
|
||||||
|
---
|
||||||
|
function get_git_conflict()
|
||||||
|
local file = io.popen("git diff --name-only --diff-filter=U 2>nul")
|
||||||
|
for line in file:lines() do
|
||||||
|
file:close()
|
||||||
|
return true;
|
||||||
|
end
|
||||||
|
file:close()
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Get the status of working dir
|
-- Get the status of working dir
|
||||||
-- @return {bool}
|
-- @return {bool}
|
||||||
@ -257,7 +272,8 @@ local function git_prompt_filter()
|
|||||||
-- Colors for git status
|
-- Colors for git status
|
||||||
local colors = {
|
local colors = {
|
||||||
clean = "\x1b[1;37;40m",
|
clean = "\x1b[1;37;40m",
|
||||||
dirty = "\x1b[31;1m",
|
dirty = "\x1b[33;3m",
|
||||||
|
conflict = "\x1b[31;1m"
|
||||||
}
|
}
|
||||||
|
|
||||||
local git_dir = get_git_dir()
|
local git_dir = get_git_dir()
|
||||||
@ -267,10 +283,16 @@ local function git_prompt_filter()
|
|||||||
local color
|
local color
|
||||||
if branch then
|
if branch then
|
||||||
-- Has branch => therefore it is a git folder, now figure out status
|
-- Has branch => therefore it is a git folder, now figure out status
|
||||||
if get_git_status() then
|
local gitStatus = get_git_status()
|
||||||
|
local gitConflict = get_git_conflict()
|
||||||
|
|
||||||
|
color = colors.dirty
|
||||||
|
if gitStatus then
|
||||||
color = colors.clean
|
color = colors.clean
|
||||||
else
|
end
|
||||||
color = colors.dirty
|
|
||||||
|
if gitConflict then
|
||||||
|
color = colors.conflict
|
||||||
end
|
end
|
||||||
|
|
||||||
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..branch..")")
|
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..branch..")")
|
||||||
@ -368,26 +390,12 @@ for _,lua_module in ipairs(clink.find_files(completions_dir..'*.lua')) do
|
|||||||
end
|
end
|
||||||
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
|
if clink.get_env('CMDER_USER_CONFIG') then
|
||||||
local cmder_user_config_dir = clink.get_env('CMDER_USER_CONFIG')..'/'
|
local cmder_config_dir = clink.get_env('CMDER_ROOT')..'/config/'
|
||||||
for _,lua_module in ipairs(clink.find_files(cmder_user_config_dir..'*.lua')) do
|
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
|
local filename = cmder_config_dir..lua_module
|
||||||
if not string.match(lua_module, '^_.*') then
|
-- use dofile instead of require because require caches loaded modules
|
||||||
local filename = cmder_user_config_dir..lua_module
|
-- so config reloading using Alt-Q won't reload updated modules.
|
||||||
-- use dofile instead of require because require caches loaded modules
|
dofile(filename)
|
||||||
-- so config reloading using Alt-Q won't reload updated modules.
|
|
||||||
dofile(filename)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
19
vendor/init.bat
vendored
19
vendor/init.bat
vendored
@ -137,14 +137,14 @@ if not defined TERM set TERM=cygwin
|
|||||||
:: also check that we have a recent enough version of git by examining the version string
|
:: also check that we have a recent enough version of git by examining the version string
|
||||||
setlocal enabledelayedexpansion
|
setlocal enabledelayedexpansion
|
||||||
if defined GIT_INSTALL_ROOT (
|
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 :SPECIFIED_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
|
:: get the version information for vendored git binary
|
||||||
%lib_git% read_version VENDORED "%CMDER_ROOT%\vendor\git-for-windows\cmd"
|
%lib_git% read_version VENDORED "%CMDER_ROOT%\vendor\git-for-windows\cmd"
|
||||||
%lib_git% validate_version VENDORED !GIT_VERSION_VENDORED!
|
%lib_git% validate_version VENDORED %GIT_VERSION_VENDORED%
|
||||||
|
|
||||||
:: check if git is in path...
|
:: check if git is in path...
|
||||||
for /F "delims=" %%F in ('where git.exe 2^>nul') do (
|
for /F "delims=" %%F in ('where git.exe 2^>nul') do (
|
||||||
@ -189,12 +189,22 @@ for /F "delims=" %%F in ('where git.exe 2^>nul') do (
|
|||||||
:VENDORED_GIT
|
:VENDORED_GIT
|
||||||
if exist "%CMDER_ROOT%\vendor\git-for-windows" (
|
if exist "%CMDER_ROOT%\vendor\git-for-windows" (
|
||||||
set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows"
|
set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows"
|
||||||
|
%lib_console% debug_output "Using vendored Git from '!GIT_INSTALL_ROOT!..."
|
||||||
%lib_path% enhance_path "!GIT_INSTALL_ROOT!\cmd"
|
%lib_path% enhance_path "!GIT_INSTALL_ROOT!\cmd"
|
||||||
|
goto :CONFIGURE_GIT
|
||||||
) else (
|
) else (
|
||||||
goto :NO_GIT
|
goto :NO_GIT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
:SPECIFIED_GIT
|
||||||
|
%lib_console% debug_output "Using /GIT_INSTALL_ROOT from '%GIT_INSTALL_ROOT%..."
|
||||||
|
goto :CONFIGURE_GIT
|
||||||
|
|
||||||
:FOUND_GIT
|
:FOUND_GIT
|
||||||
|
%lib_console% debug_output "Using found Git from '%GIT_INSTALL_ROOT%..."
|
||||||
|
goto :CONFIGURE_GIT
|
||||||
|
|
||||||
|
:CONFIGURE_GIT
|
||||||
:: Add git to the path
|
:: Add git to the path
|
||||||
if defined GIT_INSTALL_ROOT (
|
if defined GIT_INSTALL_ROOT (
|
||||||
rem add the unix commands at the end to not shadow windows commands like more
|
rem add the unix commands at the end to not shadow windows commands like more
|
||||||
@ -326,12 +336,12 @@ if not exist "%initialConfig%" (
|
|||||||
echo Creating user startup file: "%initialConfig%"
|
echo Creating user startup file: "%initialConfig%"
|
||||||
(
|
(
|
||||||
echo :: use this file to run your own startup commands
|
echo :: use this file to run your own startup commands
|
||||||
echo :: use in front of the command to prevent printing the command
|
echo :: use in front of the command to prevent printing the command
|
||||||
echo.
|
echo.
|
||||||
echo :: uncomment this to have the ssh agent load when cmder starts
|
echo :: uncomment this to have the ssh agent load when cmder starts
|
||||||
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-agent.cmd"
|
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-agent.cmd"
|
||||||
echo.
|
echo.
|
||||||
echo :: uncomment this next two lines to use pageant as the ssh authentication agent
|
echo :: uncomment the next two lines to use pageant as the ssh authentication agent
|
||||||
echo :: SET SSH_AUTH_SOCK=/tmp/.ssh-pageant-auth-sock
|
echo :: SET SSH_AUTH_SOCK=/tmp/.ssh-pageant-auth-sock
|
||||||
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-pageant.cmd"
|
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-pageant.cmd"
|
||||||
echo.
|
echo.
|
||||||
@ -356,5 +366,6 @@ if "%CMDER_ALIASES%" == "1" if exist "%CMDER_ROOT%\bin\alias.bat" if exist "%CMD
|
|||||||
)
|
)
|
||||||
|
|
||||||
set initialConfig=
|
set initialConfig=
|
||||||
|
set CMDER_CONFIGURED=1
|
||||||
|
|
||||||
exit /b
|
exit /b
|
||||||
|
14
vendor/lib/lib_git.cmd
vendored
14
vendor/lib/lib_git.cmd
vendored
@ -53,8 +53,8 @@ exit /b
|
|||||||
:: get the git version in the provided directory
|
:: get the git version in the provided directory
|
||||||
for /F "tokens=1,2,3 usebackq" %%A in (`"%git_executable%" --version 2^>nul`) do (
|
for /F "tokens=1,2,3 usebackq" %%A in (`"%git_executable%" --version 2^>nul`) do (
|
||||||
if /i "%%A %%B" == "git version" (
|
if /i "%%A %%B" == "git version" (
|
||||||
set "GIT_VERSION_%~1=%%C"
|
set "GIT_VERSION=%%C"
|
||||||
%lib_console% debug_output :read_version "Env Var - GIT_VERSION_%~1=%%C"
|
%lib_console% debug_output :read_version "Env Var - GIT_VERSION_%~1=!GIT_VERSION!"
|
||||||
) else (
|
) else (
|
||||||
%lib_console% show_error "git --version" returned an inproper version string!
|
%lib_console% show_error "git --version" returned an inproper version string!
|
||||||
pause
|
pause
|
||||||
@ -62,7 +62,7 @@ exit /b
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
endlocal & set GIT_VERSION%~1=!GIT_VERSION%~1!
|
endlocal & set "GIT_VERSION_%~1=%GIT_VERSION%"
|
||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
:parse_version
|
:parse_version
|
||||||
@ -92,6 +92,7 @@ exit /b
|
|||||||
|
|
||||||
setlocal enabledelayedexpansion
|
setlocal enabledelayedexpansion
|
||||||
:: process a `x.x.x.xxxx.x` formatted string
|
:: process a `x.x.x.xxxx.x` formatted string
|
||||||
|
%lib_console% debug_output :parse_version "ARGV[1]=%~1, ARGV[2]=%~2"
|
||||||
for /F "tokens=1-3* delims=.,-" %%A in ("%2") do (
|
for /F "tokens=1-3* delims=.,-" %%A in ("%2") do (
|
||||||
set "%~1_MAJOR=%%A"
|
set "%~1_MAJOR=%%A"
|
||||||
set "%~1_MINOR=%%B"
|
set "%~1_MINOR=%%B"
|
||||||
@ -121,6 +122,7 @@ exit /b
|
|||||||
:::-------------------------------------------------------------------------------
|
:::-------------------------------------------------------------------------------
|
||||||
|
|
||||||
:: now parse the version information into the corresponding variables
|
:: now parse the version information into the corresponding variables
|
||||||
|
%lib_console% debug_output :validate_version "ARGV[1]=%~1, ARGV[2]=%~2"
|
||||||
call :parse_version %~1 %~2
|
call :parse_version %~1 %~2
|
||||||
|
|
||||||
:: ... and maybe display it, for debugging purposes.
|
:: ... and maybe display it, for debugging purposes.
|
||||||
@ -148,9 +150,9 @@ exit /b
|
|||||||
:: checks all major, minor, patch and build variables for the given arguments.
|
:: 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.
|
:: 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 Comparing:
|
||||||
:: %lib_console% debug_output %~1: !%~1_MAJOR!.!%~1_MINOR!.!%~1_PATCH!.!%~1_BUILD!
|
%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 %~2: !%~2_MAJOR!.!%~2_MINOR!.!%~2_PATCH!.!%~2_BUILD!
|
||||||
|
|
||||||
if !%~1_MAJOR! GTR !%~2_MAJOR! (exit /b 1)
|
if !%~1_MAJOR! GTR !%~2_MAJOR! (exit /b 1)
|
||||||
if !%~1_MAJOR! LSS !%~2_MAJOR! (exit /b -1)
|
if !%~1_MAJOR! LSS !%~2_MAJOR! (exit /b -1)
|
||||||
|
18
vendor/lib/lib_path.cmd
vendored
18
vendor/lib/lib_path.cmd
vendored
@ -52,19 +52,23 @@ exit /b
|
|||||||
set "position="
|
set "position="
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set found=0
|
||||||
set "find_query=%add_path%"
|
set "find_query=%add_path%"
|
||||||
set "find_query=%find_query:\=\\%"
|
set "find_query=%find_query:\=\\%"
|
||||||
set "find_query=%find_query: =\ %"
|
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%\"$"
|
|
||||||
if "!ERRORLEVEL!" == "0" set found=1
|
|
||||||
|
|
||||||
|
if "%CMDER_CONFIGURED%" == "1" (
|
||||||
|
%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" (
|
if "!found!" == "0" (
|
||||||
echo "%path%"|findstr >nul /i /r ";%find_query%;"
|
if "%CMDER_CONFIGURED%" == "1" (
|
||||||
if "!ERRORLEVEL!" == "0" set found=1
|
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!"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user