mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 09:49:12 +08:00
Describe why PS functions are called by namespace
As the prompt function is called all the time, specifically namespace the cmldets it uses to avoid them being hijacked in the user session.
This commit is contained in:
parent
010049a849
commit
b349b19869
8
vendor/profile.ps1
vendored
8
vendor/profile.ps1
vendored
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user