mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 09:49:12 +08:00
Merge pull request #2779 from cmderdev/development
Improvements to shells and general fixes
This commit is contained in:
commit
e0ade8f3f1
@ -5,7 +5,12 @@ SET CMDER_ROOT=%~dp0
|
|||||||
@if "%CMDER_ROOT:~-1%" == "\" SET CMDER_ROOT=%CMDER_ROOT:~0,-1%
|
@if "%CMDER_ROOT:~-1%" == "\" SET CMDER_ROOT=%CMDER_ROOT:~0,-1%
|
||||||
|
|
||||||
if not exist "%CMDER_ROOT%\config\user_ConEmu.xml" (
|
if not exist "%CMDER_ROOT%\config\user_ConEmu.xml" (
|
||||||
copy "%CMDER_ROOT%\vendor\ConEmu.xml.default" "%CMDER_ROOT%\config\user_ConEmu.xml"
|
if not exist "%CMDER_ROOT%\config" mkdir "%CMDER_ROOT%\config" 2>nul
|
||||||
|
copy "%CMDER_ROOT%\vendor\ConEmu.xml.default" "%CMDER_ROOT%\config\user_ConEmu.xml" 1>nul
|
||||||
|
if %errorlevel% neq 0 (
|
||||||
|
echo ERROR: CMDER Initialization has Failed
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if exist "%~1" (
|
if exist "%~1" (
|
||||||
|
@ -88,7 +88,7 @@ if ($Compile) {
|
|||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-Not $noVendor) {
|
if (-not $noVendor) {
|
||||||
# Check for requirements
|
# Check for requirements
|
||||||
Ensure-Exists $sourcesPath
|
Ensure-Exists $sourcesPath
|
||||||
Ensure-Executable "7z"
|
Ensure-Executable "7z"
|
||||||
@ -162,7 +162,7 @@ if (-Not $noVendor) {
|
|||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-Not $Compile -Or $noVendor) {
|
if (-not $Compile -or $noVendor) {
|
||||||
Write-Warning "You are not building the full project, Use -Compile without -noVendor"
|
Write-Warning "You are not building the full project, Use -Compile without -noVendor"
|
||||||
Write-Warning "This cannot be a release. Test build only!"
|
Write-Warning "This cannot be a release. Test build only!"
|
||||||
return
|
return
|
||||||
|
@ -55,7 +55,7 @@ function Match-Filenames {
|
|||||||
|
|
||||||
$position = 0
|
$position = 0
|
||||||
|
|
||||||
if ([String]::IsNullOrEmpty($filename) -Or [String]::IsNullOrEmpty($filenameDownload)) {
|
if ([String]::IsNullOrEmpty($filename) -or [String]::IsNullOrEmpty($filenameDownload)) {
|
||||||
throw "Either one or both filenames are empty!"
|
throw "Either one or both filenames are empty!"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,15 +88,15 @@ function Fetch-DownloadUrl {
|
|||||||
|
|
||||||
$url = [uri] $urlStr
|
$url = [uri] $urlStr
|
||||||
|
|
||||||
if ((-Not $url) -Or ($null -eq $url) -Or ($url -eq '')) {
|
if ((-not $url) -or ($null -eq $url) -or ($url -eq '')) {
|
||||||
throw "Failed to parse url: $urlStr"
|
throw "Failed to parse url: $urlStr"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-Not ("http", "https" -Contains $url.Scheme)) {
|
if (-not ("http", "https" -contains $url.Scheme)) {
|
||||||
throw "unknown source scheme: $($url.Scheme)"
|
throw "unknown source scheme: $($url.Scheme)"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-Not ($url.Host -ilike "*github.com")) {
|
if (-not ($url.Host -ilike "*github.com")) {
|
||||||
throw "unknown source domain: $($url.Host)"
|
throw "unknown source domain: $($url.Host)"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,12 +116,12 @@ function Fetch-DownloadUrl {
|
|||||||
|
|
||||||
$charCount = 0
|
$charCount = 0
|
||||||
|
|
||||||
if (-Not ($info -Is [array])) {
|
if (-not ($info -is [array])) {
|
||||||
throw "The response received from API server is invalid"
|
throw "The response received from API server is invalid"
|
||||||
}
|
}
|
||||||
|
|
||||||
:loop foreach ($i in $info) {
|
:loop foreach ($i in $info) {
|
||||||
if (-Not ($i.assets -Is [array])) {
|
if (-not ($i.assets -is [array])) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,12 +157,12 @@ function Fetch-DownloadUrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Special case for archive downloads of repository
|
# Special case for archive downloads of repository
|
||||||
if (($null -eq $downloadLinks) -Or (-Not $downloadLinks)) {
|
if (($null -eq $downloadLinks) -or (-not $downloadLinks)) {
|
||||||
if ((($p | % { $_.Trim('/') }) -Contains "archive") -And $info[0].tag_name) {
|
if ((($p | ForEach-Object { $_.Trim('/') }) -contains "archive") -and $info[0].tag_name) {
|
||||||
for ($i = 0; $i -lt $p.Length; $i++) {
|
for ($i = 0; $i -lt $p.Length; $i++) {
|
||||||
if ($p[$i].Trim('/') -eq "archive") {
|
if ($p[$i].Trim('/') -eq "archive") {
|
||||||
$p[$i + 1] = $info[0].tag_name + ".zip"
|
$p[$i + 1] = $info[0].tag_name + ".zip"
|
||||||
$downloadLinks = $url.Scheme + "://" + $url.Host + ($p -Join '')
|
$downloadLinks = $url.Scheme + "://" + $url.Host + ($p -join '')
|
||||||
return $downloadLinks
|
return $downloadLinks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,11 +188,11 @@ function Fetch-DownloadUrl {
|
|||||||
|
|
||||||
$downloadLinks = $temp | Where-Object { (Match-Filenames $url $_ true) -eq $charCount }
|
$downloadLinks = $temp | Where-Object { (Match-Filenames $url $_ true) -eq $charCount }
|
||||||
|
|
||||||
if (($null -eq $downloadLinks) -Or (-Not $downloadLinks)) {
|
if (($null -eq $downloadLinks) -or (-not $downloadLinks)) {
|
||||||
throw "No suitable download links matched for the url!"
|
throw "No suitable download links matched for the url!"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-Not($downloadLinks -is [String])) {
|
if (-not($downloadLinks -is [String])) {
|
||||||
throw "Found multiple matches for the same url:`n" + $downloadLinks
|
throw "Found multiple matches for the same url:`n" + $downloadLinks
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ foreach ($s in $sources) {
|
|||||||
|
|
||||||
$downloadUrl = Fetch-DownloadUrl $s.url
|
$downloadUrl = Fetch-DownloadUrl $s.url
|
||||||
|
|
||||||
if (($null -eq $downloadUrl) -Or ($downloadUrl -eq '')) {
|
if (($null -eq $downloadUrl) -or ($downloadUrl -eq '')) {
|
||||||
Write-Verbose "No new links were found"
|
Write-Verbose "No new links were found"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -222,15 +222,15 @@ foreach ($s in $sources) {
|
|||||||
|
|
||||||
$version = ''
|
$version = ''
|
||||||
|
|
||||||
if ( ($url.Segments[-3] -eq "download/") -And ($url.Segments[-2].StartsWith("v")) ) {
|
if (($url.Segments[-3] -eq "download/") -and ($url.Segments[-2].StartsWith("v"))) {
|
||||||
$version = $url.Segments[-2].TrimStart('v').TrimEnd('/')
|
$version = $url.Segments[-2].TrimStart('v').TrimEnd('/')
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ($url.Segments[-2] -eq "archive/") ) {
|
if (($url.Segments[-2] -eq "archive/")) {
|
||||||
$version = [System.IO.Path]::GetFileNameWithoutExtension($url.Segments[-1].TrimStart('v').TrimEnd('/'))
|
$version = [System.IO.Path]::GetFileNameWithoutExtension($url.Segments[-1].TrimStart('v').TrimEnd('/'))
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $version -eq '' ) {
|
if ($version -eq '') {
|
||||||
throw "Unable to extract version from url string"
|
throw "Unable to extract version from url string"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,11 +255,11 @@ if ($count -eq 0) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $Env:APPVEYOR -eq 'True' ) {
|
if ($Env:APPVEYOR -eq 'True') {
|
||||||
Add-AppveyorMessage -Message "Successfully updated $count dependencies." -Category Information
|
Add-AppveyorMessage -Message "Successfully updated $count dependencies." -Category Information
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $Env:GITHUB_ACTIONS -eq 'true' ) {
|
if ($Env:GITHUB_ACTIONS -eq 'true') {
|
||||||
Write-Output "::notice title=Task Complete::Successfully updated $count dependencies."
|
Write-Output "::notice title=Task Complete::Successfully updated $count dependencies."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,17 +32,19 @@ function Delete-Existing($path) {
|
|||||||
function Extract-Archive($source, $target) {
|
function Extract-Archive($source, $target) {
|
||||||
Write-Verbose $("Extracting Archive '$cmder_root\vendor\" + $source.replace('/','\') + " to '$cmder_root\vendor\$target'")
|
Write-Verbose $("Extracting Archive '$cmder_root\vendor\" + $source.replace('/','\') + " to '$cmder_root\vendor\$target'")
|
||||||
Invoke-Expression "7z x -y -o`"$($target)`" `"$source`" > `$null"
|
Invoke-Expression "7z x -y -o`"$($target)`" `"$source`" > `$null"
|
||||||
if ($lastexitcode -ne 0) {
|
if ($LastExitCode -ne 0) {
|
||||||
Write-Error "Extracting of $source failed"
|
Write-Error "Extracting of $source failed"
|
||||||
}
|
}
|
||||||
Remove-Item $source
|
Remove-Item $source
|
||||||
}
|
}
|
||||||
|
|
||||||
function Create-Archive($source, $target, $params) {
|
function Create-Archive($source, $target, $params) {
|
||||||
$command = "7z a -xr@`"$source\packignore`" $params `"$target`" `"$source\*`" > `$null"
|
$command = "7z a -x@`"$source\packignore`" $params `"$target`" `"*`" > `$null"
|
||||||
Write-Verbose "Creating Archive from '$source' in '$target' with parameters '$params'"
|
Write-Verbose "Creating Archive from '$source' in '$target' with parameters '$params'"
|
||||||
|
Push-Location $source
|
||||||
Invoke-Expression $command
|
Invoke-Expression $command
|
||||||
if ($lastexitcode -ne 0) {
|
Pop-Location
|
||||||
|
if ($LastExitCode -ne 0) {
|
||||||
Write-Error "Compressing $source failed"
|
Write-Error "Compressing $source failed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,7 +56,7 @@ function Flatten-Directory($name) {
|
|||||||
$moving = "$($name)_moving"
|
$moving = "$($name)_moving"
|
||||||
Rename-Item $name -NewName $moving
|
Rename-Item $name -NewName $moving
|
||||||
Write-Verbose "Flattening the '$name' directory..."
|
Write-Verbose "Flattening the '$name' directory..."
|
||||||
$child = (Get-Childitem $moving)[0] | Resolve-Path
|
$child = (Get-ChildItem $moving)[0] | Resolve-Path
|
||||||
Move-Item -Path $child -Destination $name
|
Move-Item -Path $child -Destination $name
|
||||||
Remove-Item -Recurse $moving
|
Remove-Item -Recurse $moving
|
||||||
}
|
}
|
||||||
@ -78,7 +80,7 @@ function Set-GHVariable {
|
|||||||
Write-Verbose "Setting CI variable $Name to $Value" -Verbose
|
Write-Verbose "Setting CI variable $Name to $Value" -Verbose
|
||||||
|
|
||||||
if ($env:GITHUB_ENV) {
|
if ($env:GITHUB_ENV) {
|
||||||
echo "$Name=$Value" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
Write-Output "$Name=$Value" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +132,7 @@ function Parse-Changelog($file) {
|
|||||||
[regex]$regex = '^## \[(?<version>[\w\-\.]+)\]\([^\n()]+\)\s+\([^\n()]+\)$';
|
[regex]$regex = '^## \[(?<version>[\w\-\.]+)\]\([^\n()]+\)\s+\([^\n()]+\)$';
|
||||||
|
|
||||||
# Find the first match of the version string which means the latest version
|
# Find the first match of the version string which means the latest version
|
||||||
$version = Select-String -Path $file -Pattern $regex | Select-Object -First 1 | % { $_.Matches.Groups[1].Value }
|
$version = Select-String -Path $file -Pattern $regex | Select-Object -First 1 | ForEach-Object { $_.Matches.Groups[1].Value }
|
||||||
|
|
||||||
return $version
|
return $version
|
||||||
}
|
}
|
||||||
@ -226,12 +228,12 @@ function Download-File {
|
|||||||
|
|
||||||
$useBitTransfer = $null -ne (Get-Module -Name BitsTransfer -ListAvailable) -and ($PSVersionTable.PSVersion.Major -le 5)
|
$useBitTransfer = $null -ne (Get-Module -Name BitsTransfer -ListAvailable) -and ($PSVersionTable.PSVersion.Major -le 5)
|
||||||
|
|
||||||
$File = $File -Replace "/", "\"
|
$File = $File -replace "/", "\"
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($useBitTransfer) {
|
if ($useBitTransfer) {
|
||||||
Start-BitsTransfer -Source $Url -Destination $File -DisplayName "Downloading $Url to $File"
|
Start-BitsTransfer -Source $Url -Destination $File -DisplayName "Downloading '$Url' to $File"
|
||||||
Return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
8
vendor/clink.lua
vendored
8
vendor/clink.lua
vendored
@ -28,21 +28,21 @@ end
|
|||||||
|
|
||||||
|
|
||||||
local function get_clean_color()
|
local function get_clean_color()
|
||||||
return clean_color or "\x1b[1;37;49m"
|
return clean_color or "\x1b[37;1m" -- White, Bold
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function get_dirty_color()
|
local function get_dirty_color()
|
||||||
return dirty_color or "\x1b[33;3m"
|
return dirty_color or "\x1b[33;3m" -- Yellow, Italic
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function get_conflict_color()
|
local function get_conflict_color()
|
||||||
return conflict_color or "\x1b[31;1m"
|
return conflict_color or "\x1b[31;1m" -- Red, Bold
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_unknown_color()
|
local function get_unknown_color()
|
||||||
return unknown_color or "\x1b[37;1m"
|
return unknown_color or "\x1b[37;1m" -- White, Bold
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
|
10
vendor/cmder_prompt_config.lua.default
vendored
10
vendor/cmder_prompt_config.lua.default
vendored
@ -45,7 +45,9 @@ prompt_overrideSvnStatusOptIn = false
|
|||||||
|
|
||||||
-- Prompt Attributes
|
-- Prompt Attributes
|
||||||
--
|
--
|
||||||
-- Colors
|
-- Colors: https://github.com/cmderdev/cmder/wiki/Customization#list-of-colors
|
||||||
|
-- Effects: https://github.com/cmderdev/cmder/wiki/Customization#list-of-effects
|
||||||
|
--
|
||||||
-- Green: "\x1b[1;33;49m"
|
-- Green: "\x1b[1;33;49m"
|
||||||
-- Yellow: "\x1b[1;32;49m"
|
-- Yellow: "\x1b[1;32;49m"
|
||||||
-- Light Grey: "\x1b[1;30;49m"
|
-- Light Grey: "\x1b[1;30;49m"
|
||||||
@ -54,7 +56,7 @@ prompt_overrideSvnStatusOptIn = false
|
|||||||
uah_color = "\x1b[1;33;49m" -- Green = uah = [user]@[hostname]
|
uah_color = "\x1b[1;33;49m" -- Green = uah = [user]@[hostname]
|
||||||
cwd_color = "\x1b[1;32;49m" -- Yellow cwd = Current Working Directory
|
cwd_color = "\x1b[1;32;49m" -- Yellow cwd = Current Working Directory
|
||||||
lamb_color = "\x1b[1;30;49m" -- Light Grey = Lambda Color
|
lamb_color = "\x1b[1;30;49m" -- Light Grey = Lambda Color
|
||||||
clean_color = "\x1b[1;37;49m"
|
clean_color = "\x1b[37;1m"
|
||||||
dirty_color = "\x1b[33;3m"
|
dirty_color = "\x1b[33;3m" -- Yellow, Italic
|
||||||
conflict_color = "\x1b[31;1m"
|
conflict_color = "\x1b[31;1m" -- Red, Bold
|
||||||
unknown_color = "\x1b[37;1m" -- White = No VCS Status Branch Color
|
unknown_color = "\x1b[37;1m" -- White = No VCS Status Branch Color
|
||||||
|
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
|
:: Include Cmder libraries
|
||||||
call "%cmder_root%\vendor\bin\cexec.cmd" /setpath
|
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_base"
|
||||||
call "%cmder_root%\vendor\lib\lib_path"
|
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_git"
|
||||||
call "%cmder_root%\vendor\lib\lib_profile"
|
call "%cmder_root%\vendor\lib\lib_profile"
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
|
|||||||
set "GIT_INSTALL_ROOT=%~2"
|
set "GIT_INSTALL_ROOT=%~2"
|
||||||
shift
|
shift
|
||||||
) else (
|
) 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
|
exit /b
|
||||||
)
|
)
|
||||||
) else if /i "%1" == "/nix_tools" (
|
) else if /i "%1" == "/nix_tools" (
|
||||||
@ -111,7 +111,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
|
|||||||
set "HOME=%~2"
|
set "HOME=%~2"
|
||||||
shift
|
shift
|
||||||
) else (
|
) 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
|
exit /b
|
||||||
)
|
)
|
||||||
) else if /i "%1" == "/svn_ssh" (
|
) else if /i "%1" == "/svn_ssh" (
|
||||||
@ -124,6 +124,13 @@ call "%cmder_root%\vendor\lib\lib_profile"
|
|||||||
goto :var_loop
|
goto :var_loop
|
||||||
|
|
||||||
:start
|
: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
|
:: Sets CMDER_SHELL, CMDER_CLINK, CMDER_ALIASES variables
|
||||||
%lib_base% cmder_shell
|
%lib_base% cmder_shell
|
||||||
%print_debug% init.bat "Env Var - CMDER_ROOT=%CMDER_ROOT%"
|
%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%
|
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
|
:: Pick right version of Clink
|
||||||
if "%PROCESSOR_ARCHITECTURE%"=="x86" (
|
if "%PROCESSOR_ARCHITECTURE%"=="x86" (
|
||||||
set clink_architecture=x86
|
set clink_architecture=x86
|
||||||
set architecture_bits=32
|
set architecture_bits=32
|
||||||
) else (
|
) else if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
|
||||||
set clink_architecture=x64
|
set clink_architecture=x64
|
||||||
set architecture_bits=64
|
set architecture_bits=64
|
||||||
|
) else (
|
||||||
|
%print_warning% "Incompatible Processor Detetected: %PROCESSOR_ARCHITECTURE%"
|
||||||
|
set CMDER_CLINK=0
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%CMDER_CLINK%" == "1" (
|
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"
|
"%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_CONFIG_DIR%" --scripts "%CMDER_ROOT%\vendor"
|
||||||
|
|
||||||
if errorlevel 1 (
|
if errorlevel 1 (
|
||||||
%print_error% "Failed to initialize Clink with error code: %errorlevel%"
|
%print_error% "Clink initilization has failed with error code: %errorlevel%"
|
||||||
)
|
)
|
||||||
) else (
|
) 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" (
|
if "%CMDER_CONFIGURED%" GTR "1" (
|
||||||
@ -265,7 +289,7 @@ goto :CONFIGURE_GIT
|
|||||||
:: Add git to the path
|
:: Add git to the path
|
||||||
if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" %lib_path% enhance_path "%GIT_INSTALL_ROOT%\cmd" ""
|
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 (
|
if %nix_tools% equ 1 (
|
||||||
%print_verbose% "Preferring Windows commands"
|
%print_verbose% "Preferring Windows commands"
|
||||||
set "path_position=append"
|
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
|
set CMDER_SHELL=%~n1
|
||||||
if not defined CMDER_CLINK (
|
if not defined CMDER_CLINK (
|
||||||
set CMDER_CLINK=1
|
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 (
|
if not defined CMDER_ALIASES (
|
||||||
set CMDER_ALIASES=1
|
set CMDER_ALIASES=1
|
||||||
if "%CMDER_SHELL%" equ "tcc" set CMDER_ALIASES=0
|
|
||||||
if "%CMDER_SHELL%" equ "tccle" set CMDER_ALIASES=0
|
|
||||||
)
|
)
|
||||||
exit /b
|
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.
|
:: Much faster than using "%lib_console% debug_output ..." etc.
|
||||||
set print_debug=if %debug_output% gtr 0 %lib_console% debug_output
|
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_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
|
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" (
|
if "%~1" == "/h" (
|
||||||
%lib_base% help "%~0"
|
%lib_base% help "%~0"
|
||||||
@ -83,3 +84,24 @@ exit /b
|
|||||||
|
|
||||||
echo %ESC%[91;1mERROR:%ESC%[0m %~1
|
echo %ESC%[91;1mERROR:%ESC%[0m %~1
|
||||||
exit /b
|
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
|
||||||
|
54
vendor/profile.ps1
vendored
54
vendor/profile.ps1
vendored
@ -1,6 +1,6 @@
|
|||||||
# Init Script for PowerShell
|
# Init Script for PowerShell
|
||||||
# Created as part of Cmder project
|
# Created as part of Cmder project
|
||||||
# This file must be saved using UTF-8 with BOM encoding for prompt to work correctly.
|
# NOTE: This file must be saved using UTF-8 with BOM encoding for prompt symbol to work correctly.
|
||||||
|
|
||||||
# !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
|
# !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
|
||||||
# !!! Use "%CMDER_ROOT%\config\user_profile.ps1" to add your own startup commands
|
# !!! Use "%CMDER_ROOT%\config\user_profile.ps1" to add your own startup commands
|
||||||
@ -13,7 +13,7 @@ if (!$PSScriptRoot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($ENV:CMDER_USER_CONFIG) {
|
if ($ENV:CMDER_USER_CONFIG) {
|
||||||
# Write-Host "CMDER IS ALSO USING INDIVIDUAL USER CONFIG FROM '$ENV:CMDER_USER_CONFIG'!"
|
Write-Verbose "CMDER IS ALSO USING INDIVIDUAL USER CONFIG FROM '$ENV:CMDER_USER_CONFIG'!"
|
||||||
}
|
}
|
||||||
|
|
||||||
# We do this for Powershell as Admin Sessions because CMDER_ROOT is not being set.
|
# We do this for Powershell as Admin Sessions because CMDER_ROOT is not being set.
|
||||||
@ -43,18 +43,18 @@ if(-not $moduleInstallerAvailable -and -not $env:PSModulePath.Contains($CmderMod
|
|||||||
}
|
}
|
||||||
|
|
||||||
$gitVersionVendor = (readVersion -gitPath "$ENV:CMDER_ROOT\vendor\git-for-windows\cmd")
|
$gitVersionVendor = (readVersion -gitPath "$ENV:CMDER_ROOT\vendor\git-for-windows\cmd")
|
||||||
# Write-Host "GIT VENDOR: ${gitVersionVendor}"
|
Write-Debug "GIT VENDOR: ${gitVersionVendor}"
|
||||||
|
|
||||||
# Get user installed Git Version[s] and Compare with vendored if found.
|
# Get user installed Git Version[s] and Compare with vendored if found.
|
||||||
foreach ($git in (Get-Command -ErrorAction SilentlyContinue 'git')) {
|
foreach ($git in (Get-Command -ErrorAction SilentlyContinue 'git')) {
|
||||||
# Write-Host "GIT PATH: " + $git.Path
|
Write-Debug "GIT PATH: {$git.Path}"
|
||||||
$gitDir = Split-Path -Path $git.Path
|
$gitDir = Split-Path -Path $git.Path
|
||||||
$gitDir = isGitShim -gitPath $gitDir
|
$gitDir = isGitShim -gitPath $gitDir
|
||||||
$gitVersionUser = (readVersion -gitPath $gitDir)
|
$gitVersionUser = (readVersion -gitPath $gitDir)
|
||||||
# Write-Host "GIT USER: ${gitVersionUser}"
|
Write-Debug "GIT USER: ${gitVersionUser}"
|
||||||
|
|
||||||
$useGitVersion = compare_git_versions -userVersion $gitVersionUser -vendorVersion $gitVersionVendor
|
$useGitVersion = compare_git_versions -userVersion $gitVersionUser -vendorVersion $gitVersionVendor
|
||||||
# Write-Host "Using GIT Version: ${useGitVersion}"
|
Write-Debug "Using Git Version: ${useGitVersion}"
|
||||||
|
|
||||||
# Use user installed Git
|
# Use user installed Git
|
||||||
if ($null -eq $gitPathUser) {
|
if ($null -eq $gitPathUser) {
|
||||||
@ -66,7 +66,7 @@ foreach ($git in (Get-Command -ErrorAction SilentlyContinue 'git')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($useGitVersion -eq $gitVersionUser) {
|
if ($useGitVersion -eq $gitVersionUser) {
|
||||||
# Write-Host "Using GIT Dir: ${gitDir}"
|
Write-Debug "Using Git Dir: ${gitDir}"
|
||||||
$ENV:GIT_INSTALL_ROOT = $gitPathUser
|
$ENV:GIT_INSTALL_ROOT = $gitPathUser
|
||||||
$ENV:GIT_INSTALL_TYPE = 'USER'
|
$ENV:GIT_INSTALL_TYPE = 'USER'
|
||||||
break
|
break
|
||||||
@ -79,10 +79,10 @@ if ($null -eq $ENV:GIT_INSTALL_ROOT -and $null -ne $gitVersionVendor) {
|
|||||||
$ENV:GIT_INSTALL_TYPE = 'VENDOR'
|
$ENV:GIT_INSTALL_TYPE = 'VENDOR'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Write-Host "GIT_INSTALL_ROOT: ${ENV:GIT_INSTALL_ROOT}"
|
Write-Debug "GIT_INSTALL_ROOT: ${ENV:GIT_INSTALL_ROOT}"
|
||||||
# Write-Host "GIT_INSTALL_TYPE: ${ENV:GIT_INSTALL_TYPE}"
|
Write-Debug "GIT_INSTALL_TYPE: ${ENV:GIT_INSTALL_TYPE}"
|
||||||
|
|
||||||
if (-Not ($null -eq $ENV:GIT_INSTALL_ROOT)) {
|
if ($null -ne $ENV:GIT_INSTALL_ROOT) {
|
||||||
$env:Path = Configure-Git -gitRoot "$ENV:GIT_INSTALL_ROOT" -gitType $ENV:GIT_INSTALL_TYPE -gitPathUser $gitPathUser
|
$env:Path = Configure-Git -gitRoot "$ENV:GIT_INSTALL_ROOT" -gitType $ENV:GIT_INSTALL_TYPE -gitPathUser $gitPathUser
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,21 +95,20 @@ if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Pre-assign default prompt hooks so the first run of cmder gets a working prompt.
|
# Pre-assign default prompt hooks so the first run of cmder gets a working prompt.
|
||||||
$env:gitLoaded = $false
|
$env:gitLoaded = $null
|
||||||
[ScriptBlock]$PrePrompt = {}
|
[ScriptBlock]$PrePrompt = {}
|
||||||
[ScriptBlock]$PostPrompt = {}
|
[ScriptBlock]$PostPrompt = {}
|
||||||
[ScriptBlock]$CmderPrompt = {
|
[ScriptBlock]$CmderPrompt = {
|
||||||
|
# Check if we're currently running under Admin privileges.
|
||||||
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||||
$principal = [Security.Principal.WindowsPrincipal] $identity
|
$principal = [Security.Principal.WindowsPrincipal] $identity
|
||||||
$adminRole = [Security.Principal.WindowsBuiltInRole]::Administrator
|
$adminRole = [Security.Principal.WindowsBuiltInRole]::Administrator
|
||||||
$color = "White"
|
$color = "White"
|
||||||
if ($principal.IsInRole($adminRole)) { $color = "Red" }
|
if ($principal.IsInRole($adminRole)) { $color = "Red" }
|
||||||
$Host.UI.RawUI.ForegroundColor = "White"
|
$Host.UI.RawUI.ForegroundColor = "White"
|
||||||
Microsoft.PowerShell.Utility\Write-Host -NoNewline "PS " -ForegroundColor $color
|
Microsoft.PowerShell.Utility\Write-Host "PS " -NoNewline -ForegroundColor $color
|
||||||
Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
|
Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
|
||||||
if (Get-Command git -ErrorAction SilentlyContinue) {
|
|
||||||
checkGit($pwd.ProviderPath)
|
checkGit($pwd.ProviderPath)
|
||||||
}
|
|
||||||
Microsoft.PowerShell.Utility\Write-Host "`nλ" -NoNewLine -ForegroundColor "DarkGray"
|
Microsoft.PowerShell.Utility\Write-Host "`nλ" -NoNewLine -ForegroundColor "DarkGray"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,33 +117,31 @@ $env:Path = "$Env:CMDER_ROOT\bin;$Env:CMDER_ROOT\vendor\bin;$env:Path;$Env:CMDER
|
|||||||
|
|
||||||
# Drop *.ps1 files into "$ENV:CMDER_ROOT\config\profile.d"
|
# Drop *.ps1 files into "$ENV:CMDER_ROOT\config\profile.d"
|
||||||
# to source them at startup.
|
# to source them at startup.
|
||||||
if (-Not (Test-Path -PathType container "$ENV:CMDER_ROOT\config\profile.d")) {
|
if (-not (Test-Path -PathType container "$ENV:CMDER_ROOT\config\profile.d")) {
|
||||||
New-Item -ItemType Directory -Path "$ENV:CMDER_ROOT\config\profile.d"
|
New-Item -ItemType Directory -Path "$ENV:CMDER_ROOT\config\profile.d"
|
||||||
}
|
}
|
||||||
|
|
||||||
Push-Location $ENV:CMDER_ROOT\config\profile.d
|
Push-Location $ENV:CMDER_ROOT\config\profile.d
|
||||||
foreach ($x in Get-ChildItem *.psm1) {
|
foreach ($x in Get-ChildItem *.psm1) {
|
||||||
# Write-Host Write-Host Sourcing $x
|
Write-Verbose Write-Host Sourcing $x
|
||||||
Import-Module $x
|
Import-Module $x
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($x in Get-ChildItem *.ps1) {
|
foreach ($x in Get-ChildItem *.ps1) {
|
||||||
# Write-Host Write-Host Sourcing $x
|
Write-Verbose Write-Host Sourcing $x
|
||||||
. $x
|
. $x
|
||||||
}
|
}
|
||||||
Pop-Location
|
Pop-Location
|
||||||
|
|
||||||
# Drop *.ps1 files into "$ENV:CMDER_USER_CONFIG\config\profile.d"
|
# Drop *.ps1 files into "$ENV:CMDER_USER_CONFIG\config\profile.d"
|
||||||
# to source them at startup. Requires using cmder.exe /C [cmder_user_root_path] argument
|
# to source them at startup. Requires using cmder.exe /C [cmder_user_root_path] argument
|
||||||
if ($ENV:CMDER_USER_CONFIG -ne "" -And (Test-Path "$ENV:CMDER_USER_CONFIG\profile.d")) {
|
if ($ENV:CMDER_USER_CONFIG -ne "" -and (Test-Path "$ENV:CMDER_USER_CONFIG\profile.d")) {
|
||||||
Push-Location $ENV:CMDER_USER_CONFIG\profile.d
|
Push-Location $ENV:CMDER_USER_CONFIG\profile.d
|
||||||
foreach ($x in Get-ChildItem *.psm1) {
|
foreach ($x in Get-ChildItem *.psm1) {
|
||||||
# Write-Host Write-Host Sourcing $x
|
Write-Verbose Write-Host Sourcing $x
|
||||||
Import-Module $x
|
Import-Module $x
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($x in Get-ChildItem *.ps1) {
|
foreach ($x in Get-ChildItem *.ps1) {
|
||||||
# Write-Host Write-Host Sourcing $x
|
Write-Verbose Write-Host Sourcing $x
|
||||||
. $x
|
. $x
|
||||||
}
|
}
|
||||||
Pop-Location
|
Pop-Location
|
||||||
@ -175,8 +172,10 @@ if ($ENV:CMDER_USER_CONFIG) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-Not (Test-Path $CmderUserProfilePath)) {
|
if (-not (Test-Path $CmderUserProfilePath)) {
|
||||||
Write-Host -BackgroundColor DarkGreen -ForegroundColor White "First Run: Creating user startup file: $CmderUserProfilePath"
|
$CmderUserProfilePath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($CmderUserProfilePath)
|
||||||
|
Write-Host -NoNewline "`r"
|
||||||
|
Write-Host -BackgroundColor Green -ForegroundColor Black "First Run: Creating user startup file: $CmderUserProfilePath"
|
||||||
Copy-Item "$env:CMDER_ROOT\vendor\user_profile.ps1.default" -Destination $CmderUserProfilePath
|
Copy-Item "$env:CMDER_ROOT\vendor\user_profile.ps1.default" -Destination $CmderUserProfilePath
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,20 +196,19 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
|
|||||||
#>
|
#>
|
||||||
[ScriptBlock]$Prompt = {
|
[ScriptBlock]$Prompt = {
|
||||||
$lastSUCCESS = $?
|
$lastSUCCESS = $?
|
||||||
$realLASTEXITCODE = $LASTEXITCODE
|
$realLastExitCode = $LastExitCode
|
||||||
$host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf
|
$host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf
|
||||||
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x200B)`r$([char]0x1B)[K"
|
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x200B)`r$([char]0x1B)[K"
|
||||||
if ($lastSUCCESS -Or ($LASTEXITCODE -ne 0)) {
|
if ($lastSUCCESS -or ($LastExitCode -ne 0)) {
|
||||||
Microsoft.PowerShell.Utility\Write-Host
|
Microsoft.PowerShell.Utility\Write-Host
|
||||||
}
|
}
|
||||||
PrePrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
PrePrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
||||||
CmderPrompt
|
CmderPrompt
|
||||||
PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
||||||
$global:LASTEXITCODE = $realLASTEXITCODE
|
$global:LastExitCode = $realLastExitCode
|
||||||
return " "
|
return " "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Once Created these code blocks cannot be overwritten
|
# Once Created these code blocks cannot be overwritten
|
||||||
# if (-not $(Get-Command PrePrompt).Options -match 'Constant') {Set-Item -Path function:\PrePrompt -Value $PrePrompt -Options Constant}
|
# if (-not $(Get-Command PrePrompt).Options -match 'Constant') {Set-Item -Path function:\PrePrompt -Value $PrePrompt -Options Constant}
|
||||||
# if (-not $(Get-Command CmderPrompt).Options -match 'Constant') {Set-Item -Path function:\CmderPrompt -Value $CmderPrompt -Options Constant}
|
# if (-not $(Get-Command CmderPrompt).Options -match 'Constant') {Set-Item -Path function:\CmderPrompt -Value $CmderPrompt -Options Constant}
|
||||||
|
113
vendor/psmodules/Cmder.ps1
vendored
113
vendor/psmodules/Cmder.ps1
vendored
@ -1,7 +1,7 @@
|
|||||||
function readVersion($gitPath) {
|
function readVersion($gitPath) {
|
||||||
$gitExecutable = "${gitPath}\git.exe"
|
$gitExecutable = "${gitPath}\git.exe"
|
||||||
|
|
||||||
if (!(test-path "$gitExecutable")) {
|
if (-not (Test-Path "$gitExecutable")) {
|
||||||
return $null
|
return $null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,24 +20,24 @@ function readVersion($gitPath) {
|
|||||||
function isGitShim($gitPath) {
|
function isGitShim($gitPath) {
|
||||||
# check if there's shim - and if yes follow the path
|
# check if there's shim - and if yes follow the path
|
||||||
|
|
||||||
if (test-path "${gitPath}\git.shim") {
|
if (Test-Path "${gitPath}\git.shim") {
|
||||||
$shim = (get-content "${gitPath}\git.shim")
|
$shim = (get-content "${gitPath}\git.shim")
|
||||||
($trash, $gitPath) = $shim.replace(' ','').split('=')
|
($trash, $gitPath) = $shim.replace(' ', '').split('=')
|
||||||
|
|
||||||
$gitPath=$gitPath.replace('\git.exe','')
|
$gitPath = $gitPath.replace('\git.exe', '')
|
||||||
}
|
}
|
||||||
|
|
||||||
return $gitPath.toString()
|
return $gitPath.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareVersions($userVersion, $vendorVersion) {
|
function compareVersions($userVersion, $vendorVersion) {
|
||||||
if (-not($userVersion -eq $null)) {
|
if ($null -ne $userVersion) {
|
||||||
($userMajor, $userMinor, $userPatch, $userBuild) = $userVersion.split('.', 4)
|
($userMajor, $userMinor, $userPatch, $userBuild) = $userVersion.split('.', 4)
|
||||||
} else {
|
} else {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not($vendorVersion -eq $null)) {
|
if ($null -ne $vendorVersion) {
|
||||||
($vendorMajor, $vendorMinor, $vendorPatch, $vendorBuild) = $vendorVersion.split('.', 4)
|
($vendorMajor, $vendorMinor, $vendorPatch, $vendorBuild) = $vendorVersion.split('.', 4)
|
||||||
} else {
|
} else {
|
||||||
return 1
|
return 1
|
||||||
@ -47,17 +47,17 @@ function compareVersions($userVersion, $vendorVersion) {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($userMajor -gt $vendorMajor) {return 1}
|
if ($userMajor -gt $vendorMajor) { return 1 }
|
||||||
if ($userMajor -lt $vendorMajor) {return -1}
|
if ($userMajor -lt $vendorMajor) { return -1 }
|
||||||
|
|
||||||
if ($userMinor -gt $vendorMinor) {return 1}
|
if ($userMinor -gt $vendorMinor) { return 1 }
|
||||||
if ($userMinor -lt $vendorMinor) {return -1}
|
if ($userMinor -lt $vendorMinor) { return -1 }
|
||||||
|
|
||||||
if ($userPatch -gt $vendorPatch) {return 1}
|
if ($userPatch -gt $vendorPatch) { return 1 }
|
||||||
if ($userPatch -lt $vendorPatch) {return -1}
|
if ($userPatch -lt $vendorPatch) { return -1 }
|
||||||
|
|
||||||
if ($userBuild -gt $vendorBuild) {return 1}
|
if ($userBuild -gt $vendorBuild) { return 1 }
|
||||||
if ($userBuild -lt $vendorBuild) {return -1}
|
if ($userBuild -lt $vendorBuild) { return -1 }
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -65,45 +65,48 @@ function compareVersions($userVersion, $vendorVersion) {
|
|||||||
function compare_git_versions($userVersion, $vendorVersion) {
|
function compare_git_versions($userVersion, $vendorVersion) {
|
||||||
$result = compareVersions -userVersion $userVersion -vendorVersion $vendorVersion
|
$result = compareVersions -userVersion $userVersion -vendorVersion $vendorVersion
|
||||||
|
|
||||||
# write-host "Compare Versions Result: ${result}"
|
Write-Debug "Compare Versions Result: ${result}"
|
||||||
if ($result -ge 0) {
|
if ($result -ge 0) {
|
||||||
return $userVersion
|
return $userVersion
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return $vendorVersion
|
return $vendorVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Configure-Git($gitRoot, $gitType, $gitPathUser){
|
function Configure-Git($gitRoot, $gitType, $gitPathUser) {
|
||||||
# Proposed Behavior
|
# Proposed Behavior
|
||||||
|
|
||||||
# Modify the path if we are using VENDORED Git do nothing if using USER Git.
|
# Modify the path if we are using VENDORED Git, do nothing if using USER Git.
|
||||||
# If User Git is installed but older match its path config adding paths
|
# If User Git is installed but is older, match its path config adding paths
|
||||||
# in the same path positions allowing a user to configure Cmder Git path
|
# in the same path positions allowing a user to configure Cmder Git path
|
||||||
# using locally installed Git Path Config.
|
# using locally installed Git Path Config.
|
||||||
if ($gitType -eq 'VENDOR') {
|
if ($gitType -eq 'VENDOR') {
|
||||||
# If User Git is installed replace its path config with Newer Vendored Git Path
|
# If User Git is installed replace its path config with Newer Vendored Git Path
|
||||||
if ($gitPathUser -ne '' -and $gitPathUser -ne $null) {
|
if (($null -ne $gitPathUser) -and ($gitPathUser -ne '')) {
|
||||||
# write-host "Cmder 'profile.ps1': Replacing older user Git path '$gitPathUser' with newer vendored Git path '$gitRoot' in the system path..."
|
Write-Verbose "Cmder 'profile.ps1': Replacing older user Git path '$gitPathUser' with newer vendored Git path '$gitRoot' in the system path..."
|
||||||
|
|
||||||
$newPath = ($env:path -ireplace [regex]::Escape($gitPathUser), $gitRoot)
|
$newPath = ($env:path -ireplace [regex]::Escape($gitPathUser), $gitRoot)
|
||||||
} else {
|
}
|
||||||
if (!($env:Path -match [regex]::Escape("$gitRoot\cmd"))) {
|
else {
|
||||||
# write-host "Adding $gitRoot\cmd to the path"
|
if (-not ($env:Path -match [regex]::Escape("$gitRoot\cmd"))) {
|
||||||
|
Write-Debug "Adding $gitRoot\cmd to the path"
|
||||||
$newPath = $($gitRoot + "\cmd" + ";" + $env:Path)
|
$newPath = $($gitRoot + "\cmd" + ";" + $env:Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add "$gitRoot\mingw[32|64]\bin" to the path if exists and not done already
|
# Add "$gitRoot\mingw[32|64]\bin" to the path if exists and not done already
|
||||||
if ((test-path "$gitRoot\mingw32\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\mingw32\bin"))) {
|
if ((Test-Path "$gitRoot\mingw32\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\mingw32\bin"))) {
|
||||||
# write-host "Adding $gitRoot\mingw32\bin to the path"
|
Write-Debug "Adding $gitRoot\mingw32\bin to the path"
|
||||||
$newPath = "$newPath;$gitRoot\mingw32\bin"
|
$newPath = "$newPath;$gitRoot\mingw32\bin"
|
||||||
} elseif ((test-path "$gitRoot\mingw64\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\mingw64\bin"))) {
|
}
|
||||||
# write-host "Adding $gitRoot\mingw64\bin to the path"
|
elseif ((Test-Path "$gitRoot\mingw64\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\mingw64\bin"))) {
|
||||||
|
Write-Debug "Adding $gitRoot\mingw64\bin to the path"
|
||||||
$newPath = "$newPath;$gitRoot\mingw64\bin"
|
$newPath = "$newPath;$gitRoot\mingw64\bin"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add "$gitRoot\usr\bin" to the path if exists and not done already
|
# Add "$gitRoot\usr\bin" to the path if exists and not done already
|
||||||
if ((test-path "$gitRoot\usr\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\usr\bin"))) {
|
if ((Test-Path "$gitRoot\usr\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\usr\bin"))) {
|
||||||
# write-host "Adding $gitRoot\usr\bin to the path"
|
Write-Debug "Adding $gitRoot\usr\bin to the path"
|
||||||
$newPath = "$newPath;$gitRoot\usr\bin"
|
$newPath = "$newPath;$gitRoot\usr\bin"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,53 +117,59 @@ function Configure-Git($gitRoot, $gitType, $gitPathUser){
|
|||||||
return $env:path
|
return $env:path
|
||||||
}
|
}
|
||||||
|
|
||||||
function Import-Git(){
|
function Import-Git() {
|
||||||
$GitModule = Get-Module -Name Posh-Git -ListAvailable
|
$GitModule = Get-Module -Name Posh-Git -ListAvailable
|
||||||
if($GitModule | select version | where version -le ([version]"0.6.1.20160330")){
|
if ($GitModule | Select-Object version | Where-Object version -le ([version]"0.6.1.20160330")) {
|
||||||
Import-Module Posh-Git > $null
|
Import-Module Posh-Git > $null
|
||||||
}
|
}
|
||||||
if($GitModule | select version | where version -ge ([version]"1.0.0")){
|
if ($GitModule | Select-Object version | Where-Object version -ge ([version]"1.0.0")) {
|
||||||
Import-Module Posh-Git > $null
|
Import-Module Posh-Git > $null
|
||||||
$GitPromptSettings.AnsiConsole = $false
|
$GitPromptSettings.AnsiConsole = $false
|
||||||
}
|
}
|
||||||
if(-not ($GitModule) ) {
|
if (-not $GitModule) {
|
||||||
Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder."
|
Write-Host -NoNewline "`r`n"
|
||||||
|
Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart Cmder."
|
||||||
|
Write-Host -NoNewline "`r$([char]0x1B)[A"
|
||||||
|
return $false
|
||||||
}
|
}
|
||||||
# Make sure we only run once by alawys returning true
|
# Make sure we only run once by always returning true
|
||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkGit($Path) {
|
function checkGit($Path) {
|
||||||
if (Test-Path -Path (Join-Path $Path '.git') ) {
|
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
|
||||||
if($env:gitLoaded -eq 'false') {
|
return
|
||||||
|
}
|
||||||
|
if (-not (Test-Path -Path (Join-Path $Path '.git'))) {
|
||||||
|
$SplitPath = Split-Path $path
|
||||||
|
if ($SplitPath) { checkGit($SplitPath) }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (getGitStatusSetting -eq $true) {
|
||||||
|
if ($null -eq $env:gitLoaded) {
|
||||||
$env:gitLoaded = Import-Git
|
$env:gitLoaded = Import-Git
|
||||||
}
|
}
|
||||||
|
if ($env:gitLoaded -eq $true) {
|
||||||
if (getGitStatusSetting -eq $true) {
|
|
||||||
Write-VcsStatus
|
Write-VcsStatus
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
$headContent = Get-Content (Join-Path $Path '.git/HEAD')
|
$headContent = Get-Content (Join-Path $Path '.git/HEAD')
|
||||||
if ($headContent -like "ref: refs/heads/*") {
|
if ($headContent -like "ref: refs/heads/*") {
|
||||||
$branchName = $headContent.Substring(16)
|
$branchName = $headContent.Substring(16)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$branchName = "HEAD detached at $($headContent.Substring(0, 7))"
|
$branchName = "HEAD detached at $($headContent.Substring(0, 7))"
|
||||||
}
|
}
|
||||||
Write-Host " [$branchName]" -NoNewline -ForegroundColor White
|
Write-Host " [$branchName]" -NoNewline -ForegroundColor White
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
$SplitPath = split-path $path
|
|
||||||
if ($SplitPath) {
|
|
||||||
checkGit($SplitPath)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGitStatusSetting() {
|
function getGitStatusSetting() {
|
||||||
$gitStatus = (git --no-pager config -l) | out-string
|
$gitStatus = (git --no-pager config -l) | Out-String
|
||||||
|
|
||||||
ForEach ($line in $($gitStatus -split "`r`n")) {
|
foreach ($line in $($gitStatus -split "`r`n")) {
|
||||||
if ($line -match 'cmder.status=false' -or $line -match 'cmder.psstatus=false') {
|
if (($line -match 'cmder.status=false') -or ($line -match 'cmder.psstatus=false')) {
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
vendor/psmodules/PsGet/PsGet.psm1
vendored
2
vendor/psmodules/PsGet/PsGet.psm1
vendored
@ -1818,7 +1818,7 @@ function Expand-ZipModule {
|
|||||||
|
|
||||||
# Check if powershell v3+ and .net v4.5 is available
|
# Check if powershell v3+ and .net v4.5 is available
|
||||||
$netFailed = $true
|
$netFailed = $true
|
||||||
if ( $PSVersionTable.PSVersion.Major -ge 3 -and (Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4' -Recurse | Get-ItemProperty -Name Version | Where-Object { $_.Version -like '4.5*' -Or $_.Version -ge '4.5' }) ) {
|
if ( $PSVersionTable.PSVersion.Major -ge 3 -and (Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4' -Recurse | Get-ItemProperty -Name Version | Where-Object { $_.Version -like '4.5*' -or $_.Version -ge '4.5' }) ) {
|
||||||
Write-Debug 'Attempting unzip using the .NET Framework...'
|
Write-Debug 'Attempting unzip using the .NET Framework...'
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user