mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 17:59:11 +08:00
Only write VCS Status if we're in a git repo
In an effort to speed up the prompt we will only call write-vcsstatus if there is a .git folder in the current or any parent path recursively. As this function is called every new prompt line it needs to be as fast as possible.
This commit is contained in:
parent
18fc5e37c7
commit
c466698d6b
13
vendor/profile.ps1
vendored
13
vendor/profile.ps1
vendored
@ -14,13 +14,24 @@ try {
|
|||||||
$gitStatus = $false
|
$gitStatus = $false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkGit($Path) {
|
||||||
|
if (Test-Path -Path (Join-Path $Path '.git/') ) {
|
||||||
|
Write-VcsStatus
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$SplitPath = split-path $path
|
||||||
|
if ($SplitPath) {
|
||||||
|
checkGit($SplitPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Set up a Cmder prompt, adding the git prompt parts inside git repos
|
# Set up a Cmder prompt, adding the git prompt parts inside git repos
|
||||||
function global:prompt {
|
function global:prompt {
|
||||||
$realLASTEXITCODE = $LASTEXITCODE
|
$realLASTEXITCODE = $LASTEXITCODE
|
||||||
$Host.UI.RawUI.ForegroundColor = "White"
|
$Host.UI.RawUI.ForegroundColor = "White"
|
||||||
Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
|
Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
|
||||||
Write-VcsStatus
|
|
||||||
if($gitStatus){
|
if($gitStatus){
|
||||||
|
checkGit($pwd.ProviderPath)
|
||||||
}
|
}
|
||||||
$global:LASTEXITCODE = $realLASTEXITCODE
|
$global:LASTEXITCODE = $realLASTEXITCODE
|
||||||
Write-Host "`nλ" -NoNewLine -ForegroundColor "DarkGray"
|
Write-Host "`nλ" -NoNewLine -ForegroundColor "DarkGray"
|
||||||
|
Loading…
Reference in New Issue
Block a user