Files
inshellisense/shell/shellIntegration.ps1
Chapman Pendery c13939ae02 feat: add option to hide prompt information during e2e tests (#168)
* feat: add option to hide prompt information during e2e tests

Signed-off-by: Chapman Pendery <cpendery@vt.edu>

* fix: drop hidden option header

Signed-off-by: Chapman Pendery <cpendery@vt.edu>

* fix: tests to use -T

Signed-off-by: Chapman Pendery <cpendery@vt.edu>

---------

Signed-off-by: Chapman Pendery <cpendery@vt.edu>
2024-02-15 12:13:32 -08:00

24 lines
772 B
PowerShell

$Global:__IsOriginalPrompt = $function:Prompt
function Global:__IsTestingPrompt() {
return "PS > "
}
if ($env:ISTERM_TESTING -eq "1") {
$Global:__IsOriginalPrompt = $function:__IsTestingPrompt
}
function Global:__IS-Escape-Value([string]$value) {
[regex]::Replace($value, '[\\\n;]', { param($match)
-Join (
[System.Text.Encoding]::UTF8.GetBytes($match.Value) | ForEach-Object { '\x{0:x2}' -f $_ }
)
})
}
function Global:Prompt() {
$Result = "$([char]0x1b)]6973;PS`a"
$Result += $Global:__IsOriginalPrompt.Invoke()
$Result += "$([char]0x1b)]6973;PE`a"
$Result += if ($pwd.Provider.Name -eq 'FileSystem') { "$([char]0x1b)]6973;CWD;$(__IS-Escape-Value $pwd.ProviderPath)`a" }
return $Result
}