diff --git a/Source/Classes/PowerLineTheme.ps1 b/Source/Classes/PowerLineTheme.ps1 index d530522..5327ad4 100644 --- a/Source/Classes/PowerLineTheme.ps1 +++ b/Source/Classes/PowerLineTheme.ps1 @@ -23,7 +23,9 @@ Add-MetadataConverter @{ ) PSReadLineContinuationPrompt = '$($_.PSReadLineContinuationPrompt)' PSReadLineContinuationPromptColor = '$($_.PSReadLineContinuationPromptColor)' - PSReadLineErrorColor = '$($_.PSReadLineErrorColor -join "','")' + $(if ($_.PSReadLineErrorColor) { + "PSReadLineErrorColor = '$($_.PSReadLineErrorColor -join "','")'" + }) HideErrors = $(if ($_.HideErrors) { '$true' } else { '$false' }) RepeatPrompt = '$(if ($_.RepeatPrompt) { $_.RepeatPrompt } else { 'CachedPrompt' })' SetCurrentDirectory = $(if ($_.SetCurrentDirectory) { '$true' } else { '$false' })$( diff --git a/Source/PowerLine.psd1 b/Source/PowerLine.psd1 index c96712d..c8201f5 100644 --- a/Source/PowerLine.psd1 +++ b/Source/PowerLine.psd1 @@ -40,11 +40,11 @@ FormatsToProcess = @("PowerLine.format.ps1xml") NestedModules = @() RequiredModules = @( + @{ModuleName="TerminalBlocks"; ModuleVersion="2.0.0"} # Make sure we get the fixed version of Metadata - @{ModuleName="TerminalBlocks"; ModuleVersion="1.1.0"} - @{ModuleName="Metadata"; ModuleVersion="1.5.5"} - @{ModuleName="Configuration"; ModuleVersion="1.5.1"} - @{ModuleName="Pansies"; ModuleVersion="2.4.0"} + @{ModuleName="Metadata"; ModuleVersion="1.5.7"} + @{ModuleName="Configuration"; ModuleVersion="1.6.0"} + @{ModuleName="Pansies"; ModuleVersion="2.6.1"} ) # RequiredAssemblies = "lib\PowerLine.dll" diff --git a/Source/Public/Set-PowerLinePrompt.ps1 b/Source/Public/Set-PowerLinePrompt.ps1 index 56aa3a7..ac73422 100644 --- a/Source/Public/Set-PowerLinePrompt.ps1 +++ b/Source/Public/Set-PowerLinePrompt.ps1 @@ -125,8 +125,30 @@ function Set-PowerLinePrompt { } } process { + try { + [PowerLineTheme]$Local:PowerLineConfig = $Configuration | Update-Object $PSBoundParameters + } catch { + $ConfigPath = Join-Path (Get-ConfigurationPath) "Configuration.psd1" + $Date = Get-Date -f "yyyyMMdd" + $NewPath = [IO.Path]::ChangeExtension($ConfigPath, "$Date.psd1") + $Index = 0 + while(Test-Path $NewPath) { + $Index++ + $NewPath = [IO.Path]::ChangeExtension($ConfigPath, "$Date.$Index.psd1") + } + Write-Warning "Failed to import existing config, creating default prompt. Moved old '$ConfigPath' to '$NewPath'" + Move-Item $ConfigPath $NewPath -Force - [PowerLineTheme]$Local:PowerLineConfig = $Configuration | Update-Object $PSBoundParameters + try { + # Redo the import, so they get configuration from our default file + [PowerLineTheme]$Local:PowerLineConfig = Import-Configuration -ErrorAction SilentlyContinue | Update-Object @{ + HideErrors = $HideErrors + SetCurrentDirectory = $SetCurrentDirectory + } | Update-Object $PSBoundParameters + } catch { + [PowerLineTheme]$Local:PowerLineConfig = $PSBoundParameters + } + } # Set the default cap & separator before we cast prompt blocks if ($NoBackground) {