mirror of
				https://github.com/cmderdev/cmder.git
				synced 2025-11-01 01:42:17 +08:00 
			
		
		
		
	Merge pull request #2193 from glucas/fix/2192
Fix #2192: Set default prompt hooks before loading user profile
This commit is contained in:
		
							
								
								
									
										23
									
								
								vendor/profile.ps1
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								vendor/profile.ps1
									
									
									
									
										vendored
									
									
								
							| @@ -96,6 +96,18 @@ if (Get-Module PSReadline -ErrorAction "SilentlyContinue") { | |||||||
|     Set-PSReadlineOption -ExtraPromptLineCount 1 |     Set-PSReadlineOption -ExtraPromptLineCount 1 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | # Pre assign default prompt hooks so the first run of cmder gets a working prompt. | ||||||
|  | [ScriptBlock]$PrePrompt = {} | ||||||
|  | [ScriptBlock]$PostPrompt = {} | ||||||
|  | [ScriptBlock]$CmderPrompt = { | ||||||
|  |     $Host.UI.RawUI.ForegroundColor = "White" | ||||||
|  |     Write-Host -NoNewline "$([char]0x200B)" | ||||||
|  |     Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green | ||||||
|  |     if (get-command git -erroraction silentlycontinue) { | ||||||
|  |         checkGit($pwd.ProviderPath) | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| # Enhance Path | # Enhance Path | ||||||
| $env:Path = "$Env:CMDER_ROOT\bin;$Env:CMDER_ROOT\vendor\bin;$env:Path;$Env:CMDER_ROOT" | $env:Path = "$Env:CMDER_ROOT\bin;$Env:CMDER_ROOT\vendor\bin;$env:Path;$Env:CMDER_ROOT" | ||||||
|  |  | ||||||
| @@ -172,17 +184,6 @@ if (! (Test-Path $CmderUserProfilePath) ) { | |||||||
| # This allows users to configure the prompt in their user_profile.ps1 or config\profile.d\*.ps1 | # This allows users to configure the prompt in their user_profile.ps1 or config\profile.d\*.ps1 | ||||||
| if ( $(get-command prompt).Definition -match 'PS \$\(\$executionContext.SessionState.Path.CurrentLocation\)\$\(' -and ` | if ( $(get-command prompt).Definition -match 'PS \$\(\$executionContext.SessionState.Path.CurrentLocation\)\$\(' -and ` | ||||||
|   $(get-command prompt).Definition -match '\(\$nestedPromptLevel \+ 1\)\) ";') { |   $(get-command prompt).Definition -match '\(\$nestedPromptLevel \+ 1\)\) ";') { | ||||||
|   # Pre assign the hooks so the first run of cmder gets a working prompt. |  | ||||||
|   [ScriptBlock]$PrePrompt = {} |  | ||||||
|   [ScriptBlock]$PostPrompt = {} |  | ||||||
|   [ScriptBlock]$CmderPrompt = { |  | ||||||
|       $Host.UI.RawUI.ForegroundColor = "White" |  | ||||||
|       Write-Host -NoNewline "$([char]0x200B)" |  | ||||||
|       Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green |  | ||||||
|       if (get-command git -erroraction silentlycontinue) { |  | ||||||
|           checkGit($pwd.ProviderPath) |  | ||||||
|       } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   <# |   <# | ||||||
|   This scriptblock runs every time the prompt is returned. |   This scriptblock runs every time the prompt is returned. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user