mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 09:49:12 +08:00
Fix #2192: Set default prompt hooks before loading user profile
This commit is contained in:
parent
3736508b2c
commit
7f69f15637
23
vendor/profile.ps1
vendored
23
vendor/profile.ps1
vendored
@ -96,6 +96,18 @@ if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
|
||||
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
|
||||
$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
|
||||
if ( $(get-command prompt).Definition -match 'PS \$\(\$executionContext.SessionState.Path.CurrentLocation\)\$\(' -and `
|
||||
$(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.
|
||||
|
Loading…
Reference in New Issue
Block a user