mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-11 00:39:08 +08:00
Use checkGit to hold the git state. Import posh-git at the last minute.
Import-Git now finds if the module isn't installed at all and alerts the user. But only when in a git folder.
This commit is contained in:
parent
76b2ed510d
commit
7a0a1adc02
18
vendor/profile.ps1
vendored
18
vendor/profile.ps1
vendored
@ -46,16 +46,18 @@ try {
|
|||||||
$env:Path += $(";" + $env:CMDER_ROOT + "\vendor\git-for-windows\bin")
|
$env:Path += $(";" + $env:CMDER_ROOT + "\vendor\git-for-windows\bin")
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
$gitLoaded = $false
|
||||||
Import-Module -Name "posh-git" -ErrorAction Stop >$null
|
function Import-Git($Loaded){
|
||||||
$gitStatus = $true
|
if($Loaded) { return }
|
||||||
} catch {
|
if(-not (Get-Module -Name Posh-Git -ListAvailable) ) {
|
||||||
Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder."
|
Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder."
|
||||||
$gitStatus = $false
|
}
|
||||||
|
return $true
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkGit($Path) {
|
function checkGit($Path) {
|
||||||
if (Test-Path -Path (Join-Path $Path '.git') ) {
|
if (Test-Path -Path (Join-Path $Path '.git') ) {
|
||||||
|
$gitLoaded = Import-Git $gitLoaded
|
||||||
Write-VcsStatus
|
Write-VcsStatus
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -103,9 +105,7 @@ popd
|
|||||||
[ScriptBlock]$CmderPrompt = {
|
[ScriptBlock]$CmderPrompt = {
|
||||||
$Host.UI.RawUI.ForegroundColor = "White"
|
$Host.UI.RawUI.ForegroundColor = "White"
|
||||||
Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
|
Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
|
||||||
if($gitStatus){
|
checkGit($pwd.ProviderPath)
|
||||||
checkGit($pwd.ProviderPath)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$CmderUserProfilePath = Join-Path $env:CMDER_ROOT "config\user-profile.ps1"
|
$CmderUserProfilePath = Join-Path $env:CMDER_ROOT "config\user-profile.ps1"
|
||||||
|
Loading…
Reference in New Issue
Block a user