mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
fix(pwsh): call convert-path before setting workingdirectory
Only for FileSystem psprovider
This commit is contained in:
parent
39a272af76
commit
a31d718fcb
|
@ -1,26 +1,27 @@
|
||||||
function global:Start-Utf8Process
|
function global:Start-Utf8Process {
|
||||||
{
|
param(
|
||||||
param(
|
|
||||||
[string] $FileName,
|
[string] $FileName,
|
||||||
[string] $Arguments
|
[string] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
$Process = New-Object System.Diagnostics.Process
|
$Process = New-Object System.Diagnostics.Process
|
||||||
$StartInfo = $Process.StartInfo
|
$StartInfo = $Process.StartInfo
|
||||||
$StartInfo.StandardErrorEncoding = $StartInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8
|
$StartInfo.StandardErrorEncoding = $StartInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
$StartInfo.RedirectStandardError = $StartInfo.RedirectStandardInput = $StartInfo.RedirectStandardOutput = $true
|
$StartInfo.RedirectStandardError = $StartInfo.RedirectStandardInput = $StartInfo.RedirectStandardOutput = $true
|
||||||
$StartInfo.FileName = $filename
|
$StartInfo.FileName = $filename
|
||||||
$StartInfo.Arguments = $Arguments
|
$StartInfo.Arguments = $Arguments
|
||||||
$StartInfo.UseShellExecute = $false
|
$StartInfo.UseShellExecute = $false
|
||||||
$StartInfo.WorkingDirectory = $PWD #when UseShellExecute=false, workingDirectory=""
|
if ($pwd.provider.name -eq "FileSystem") { #workingdirectory does not work with registry path
|
||||||
|
$StartInfo.WorkingDirectory = convert-path $pwd #when UseShellExecute=false, workingDirectory=""
|
||||||
|
}
|
||||||
$StartInfo.CreateNoWindow = $true
|
$StartInfo.CreateNoWindow = $true
|
||||||
$_ = $Process.Start();
|
$_ = $Process.Start();
|
||||||
$_ = $Process.WaitForExit();
|
$_ = $Process.WaitForExit();
|
||||||
$stderr = $Process.StandardError.ReadToEnd().Trim()
|
$stderr = $Process.StandardError.ReadToEnd().Trim()
|
||||||
if ($stderr -ne '') {
|
if ($stderr -ne '') {
|
||||||
$Host.UI.WriteErrorLine($stderr)
|
$Host.UI.WriteErrorLine($stderr)
|
||||||
}
|
}
|
||||||
return $Process.StandardOutput.ReadToEnd()
|
return $Process.StandardOutput.ReadToEnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
$env:POWERLINE_COMMAND = "oh-my-posh"
|
$env:POWERLINE_COMMAND = "oh-my-posh"
|
||||||
|
@ -192,7 +193,8 @@ function global:Enable-PoshTransientPrompt {
|
||||||
[Console]::OutputEncoding = [Text.Encoding]::UTF8
|
[Console]::OutputEncoding = [Text.Encoding]::UTF8
|
||||||
try {
|
try {
|
||||||
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
|
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
|
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
|
||||||
[Console]::OutputEncoding = $previousOutputEncoding
|
[Console]::OutputEncoding = $previousOutputEncoding
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue