diff --git a/docs/docs/install-customize-cmd.mdx b/docs/docs/install-customize-cmd.mdx index d88563d5..5b0c5515 100644 --- a/docs/docs/install-customize-cmd.mdx +++ b/docs/docs/install-customize-cmd.mdx @@ -21,7 +21,7 @@ Export-PoshTheme -FilePath ~/.mytheme.omp.json -Format json Once you're done editing, adjust your `$PROFILE` to use your newly created theme. ```powershell -Invoke-Expression (oh-my-posh --init --shell pwsh --config ~/.mytheme.omp.json) +oh-my-posh --init --shell pwsh --config ~/.mytheme.omp.json | Invoke-Expression ``` diff --git a/docs/docs/install-shells.mdx b/docs/docs/install-shells.mdx index 7a6caab1..1981d625 100644 --- a/docs/docs/install-shells.mdx +++ b/docs/docs/install-shells.mdx @@ -26,7 +26,7 @@ oh-my-posh --print-shell Edit `$PROFILE` in your preferred PowerShell version and add the following line. ```powershell -Invoke-Expression (oh-my-posh --init --shell pwsh --config ~/.mytheme.omp.json) +oh-my-posh --init --shell pwsh --config ~/.mytheme.omp.json | Invoke-Expression ``` Once added, reload your profile for the changes to take effect. diff --git a/packages/powershell/oh-my-posh/oh-my-posh.psm1 b/packages/powershell/oh-my-posh/oh-my-posh.psm1 index 95b0cdf2..7b24340f 100644 --- a/packages/powershell/oh-my-posh/oh-my-posh.psm1 +++ b/packages/powershell/oh-my-posh/oh-my-posh.psm1 @@ -66,7 +66,7 @@ function Set-PoshPrompt { $global:omp_global_sessionstate = $PSCmdlet.SessionState $poshCommand = Get-PoshCommand - Invoke-Expression (& $poshCommand --init --shell=pwsh --config="$config") + (& $poshCommand --init --shell=pwsh --config="$config") | Invoke-Expression } function Get-PoshThemes { diff --git a/src/main.go b/src/main.go index f3af19e5..3e7ba17c 100644 --- a/src/main.go +++ b/src/main.go @@ -223,7 +223,7 @@ func initShell(shell, configFile string) string { } switch shell { case pwsh: - return fmt.Sprintf("Invoke-Expression (@(&\"%s\" --print-init --shell=pwsh --config=\"%s\") -join \"`n\")", executable, configFile) + return fmt.Sprintf("(@(&\"%s\" --print-init --shell=pwsh --config=\"%s\") -join \"`n\") | Invoke-Expression", executable, configFile) case zsh, bash, fish: return printShellInit(shell, configFile) default: