mirror of
				https://github.com/cmderdev/cmder.git
				synced 2025-10-31 09:22:15 +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:
		
							
								
								
									
										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") | ||||
| } | ||||
|  | ||||
| try { | ||||
|     Import-Module -Name "posh-git" -ErrorAction Stop >$null | ||||
|     $gitStatus = $true | ||||
| } catch { | ||||
|     Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder." | ||||
|     $gitStatus = $false | ||||
| $gitLoaded = $false | ||||
| function Import-Git($Loaded){ | ||||
|     if($Loaded) { return } | ||||
|     if(-not (Get-Module -Name Posh-Git -ListAvailable) ) { | ||||
|         Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder." | ||||
|     } | ||||
|     return $true | ||||
| } | ||||
|  | ||||
| function checkGit($Path) { | ||||
|     if (Test-Path -Path (Join-Path $Path '.git') ) { | ||||
|         $gitLoaded = Import-Git $gitLoaded | ||||
|         Write-VcsStatus | ||||
|         return | ||||
|     } | ||||
| @@ -103,9 +105,7 @@ popd | ||||
| [ScriptBlock]$CmderPrompt = { | ||||
|     $Host.UI.RawUI.ForegroundColor = "White" | ||||
|     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" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user