From 7f69f156372de21a005f9366f2a9c7334f959d71 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Tue, 22 Oct 2019 11:17:13 -0400 Subject: [PATCH] Fix #2192: Set default prompt hooks before loading user profile --- vendor/profile.ps1 | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/vendor/profile.ps1 b/vendor/profile.ps1 index aa90974..c0dbfb1 100644 --- a/vendor/profile.ps1 +++ b/vendor/profile.ps1 @@ -44,7 +44,7 @@ function Configure-Git($GIT_INSTALL_ROOT){ if ((test-path "$GIT_INSTALL_ROOT\usr\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\usr\\bin")) { $env:path = "$env:path;$GIT_INSTALL_ROOT\usr\bin" } - + # Add "$GIT_INSTALL_ROOT\mingw[32|64]\bin" to the path if exists and not done already if ((test-path "$GIT_INSTALL_ROOT\mingw32\bin") -and -not ($env:path -match "$GIT_INSTALL_ROOT_ESC\\mingw32\\bin")) { $env:path = "$env:path;$GIT_INSTALL_ROOT\mingw32\bin" @@ -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.