Skip to content

Commit

Permalink
fix: powershell exports config files as utf8 without BOM
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlopresti authored and JanDeDobbeleer committed Mar 6, 2021
1 parent 37e96de commit 90cd37e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/powershell/oh-my-posh/oh-my-posh.psm1
Expand Up @@ -89,10 +89,15 @@ function Export-PoshTheme {

$config = $global:PoshSettings.Theme
$poshCommand = Get-PoshCommand
# Save current encoding and swap for UTF8

# Save current encoding and swap for UTF8 without BOM
$originalOutputEncoding = [Console]::OutputEncoding
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
& $poshCommand -config $config -print-config | Out-File -FilePath $FilePath
[Console]::OutputEncoding = [Text.UTF8Encoding]::new($false)

# Create Config File
$configString = & $poshCommand -config $config -print-config
[IO.File]::WriteAllLines($FilePath, $configString)

# Restore initial encoding
[Console]::OutputEncoding = $originalOutputEncoding
}
Expand Down

0 comments on commit 90cd37e

Please sign in to comment.