From b651c9a06525a68003198618cb914753dd3ac045 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Mon, 18 Jan 2021 18:58:17 +0100 Subject: [PATCH] fix(pwsh): provide full config path resolves #355 --- packages/powershell/oh-my-posh/oh-my-posh.psm1 | 4 ++-- src/init/omp.ps1 | 7 ++++--- src/main.go | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/powershell/oh-my-posh/oh-my-posh.psm1 b/packages/powershell/oh-my-posh/oh-my-posh.psm1 index 61b471b4..01aa15f1 100644 --- a/packages/powershell/oh-my-posh/oh-my-posh.psm1 +++ b/packages/powershell/oh-my-posh/oh-my-posh.psm1 @@ -32,14 +32,14 @@ function Set-PoshPrompt { $config = "$PSScriptRoot/themes/$Theme.omp.json" } elseif (Test-Path $Theme) { - $config = Resolve-Path -Path $Theme + $config = (Resolve-Path -Path $Theme).Path } else { $config = "$PSScriptRoot/themes/jandedobbeleer.omp.json" } $poshCommand = Get-PoshCommand - Invoke-Expression (& $poshCommand --init --shell pwsh --config $config) + Invoke-Expression (& $poshCommand --init --shell=pwsh --config="$config") } function Get-PoshThemes { diff --git a/src/init/omp.ps1 b/src/init/omp.ps1 index b6444997..5bcc1d3a 100644 --- a/src/init/omp.ps1 +++ b/src/init/omp.ps1 @@ -2,8 +2,9 @@ $global:PoshSettings = New-Object -TypeName PSObject -Property @{ Theme = ""; } -if (Test-Path "::CONFIG::") { - $global:PoshSettings.Theme = Resolve-Path -Path "::CONFIG::" +$config = "::CONFIG::" +if (Test-Path $config) { + $global:PoshSettings.Theme = (Resolve-Path -Path $config).Path } function global:Set-PoshContext {} @@ -44,7 +45,7 @@ function global:Set-PoshGitStatus { $config = $global:PoshSettings.Theme $cleanPWD = $PWD.ProviderPath.TrimEnd("\") $cleanPSWD = $PWD.ToString().TrimEnd("\") - $standardOut = @(&$omp "--config=$config" "--error=$errorCode" "--pwd=$cleanPWD" "--pswd=$cleanPSWD" "--execution-time=$executionTime") + $standardOut = @(&$omp --error="$errorCode" --pwd="$cleanPWD" --pswd="$cleanPSWD" --execution-time="$executionTime" --config="$config") # Restore initial encoding [Console]::OutputEncoding = $originalOutputEncoding # the ouput can be multiline, joining these ensures proper rendering by adding line breaks with `n diff --git a/src/main.go b/src/main.go index 5f0e91c8..58728e6e 100644 --- a/src/main.go +++ b/src/main.go @@ -167,7 +167,7 @@ func initShell(shell, config string) string { } switch shell { case pwsh: - return fmt.Sprintf("Invoke-Expression (@(&\"%s\" --print-init --shell pwsh --config %s) -join \"`n\")", executable, config) + return fmt.Sprintf("Invoke-Expression (@(&\"%s\" --print-init --shell=pwsh --config=\"%s\") -join \"`n\")", executable, config) case zsh, bash, fish: return printShellInit(shell, config) default: