mirror of
				https://github.com/cmderdev/cmder.git
				synced 2025-10-31 09:22:15 +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:
		
							
								
								
									
										13
									
								
								vendor/profile.ps1
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								vendor/profile.ps1
									
									
									
									
										vendored
									
									
								
							| @@ -14,13 +14,24 @@ try { | ||||
|     $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 | ||||
| function global:prompt { | ||||
|     $realLASTEXITCODE = $LASTEXITCODE | ||||
|     $Host.UI.RawUI.ForegroundColor = "White" | ||||
|     Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green | ||||
|         Write-VcsStatus | ||||
|     if($gitStatus){ | ||||
|         checkGit($pwd.ProviderPath) | ||||
|     } | ||||
|     $global:LASTEXITCODE = $realLASTEXITCODE | ||||
|     Write-Host "`nλ" -NoNewLine -ForegroundColor "DarkGray" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user