diff --git a/vendor/profile.ps1 b/vendor/profile.ps1 index 0394209..fc0f324 100644 --- a/vendor/profile.ps1 +++ b/vendor/profile.ps1 @@ -155,9 +155,14 @@ Set-Item -Path function:\PrePrompt -Value $PrePrompt -Options Constant Set-Item -Path function:\CmderPrompt -Value $CmderPrompt -Options Constant Set-Item -Path function:\PostPrompt -Value $PostPrompt -Options Constant +<# +This scriptblock runs every time the prompt is returned. +Explicitly use functions from MS namespace to protect from being overridden in the user session. +Custom prompt functions are loaded in as constants to get the same behaviour +#> [ScriptBlock]$Prompt = { $realLASTEXITCODE = $LASTEXITCODE - $host.UI.RawUI.WindowTitle = Split-Path $pwd.ProviderPath -Leaf + $host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf PrePrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline CmderPrompt Microsoft.PowerShell.Utility\Write-Host "`nλ " -NoNewLine -ForegroundColor "DarkGray" @@ -166,5 +171,6 @@ Set-Item -Path function:\PostPrompt -Value $PostPrompt -Options Constant return " " } +# Functions can be made constant only at creation time # ReadOnly at least requires `-force` to be overwritten Set-Item -Path function:\prompt -Value $Prompt -Options ReadOnly