diff --git a/scripts/Common/Software/Oh My Posh/Manage.ps1 b/scripts/Common/Software/Oh My Posh/Manage.ps1 index 394a7785..f22e2406 100644 --- a/scripts/Common/Software/Oh My Posh/Manage.ps1 +++ b/scripts/Common/Software/Oh My Posh/Manage.ps1 @@ -3,6 +3,7 @@ param ( [hashtable] $Arguments ) +. "$PSScriptRoot/../aliae/Manage.ps1"; . "$PSScriptRoot/../PowerShell/Profile.ps1"; . "$PSScriptRoot/../../Scripts/Software.ps1"; . "$PSScriptRoot/../../Types/InstallerAction.ps1"; @@ -18,4 +19,30 @@ Start-SoftwareInstaller @PSBoundParameters ` (Get-ScriptInitializer "oh-my-posh init pwsh"), (Get-ScriptInitializer "oh-my-posh completion powershell") ) -join [System.Environment]::NewLine) + } ` + -UserConfigurator { + param( + [hashtable] $Arguments + ) + + $theme = Get-UserConfig "oh-my-posh.theme"; + + if ($theme) { + $varName = "POSH_THEME"; + + if ($theme -isnot [string]) { + $root = "$($IsWindows ? $env:AppData : "~/.config")/oh-my-posh"; + $path = Join-Path $root "$($theme.name).omp.json"; + $null = New-Item -Force -ItemType Directory $root; + Copy-Item $theme.source $path; + $theme = [string] $path; + } + + if ($IsWindows) { + [System.Environment]::SetEnvironmentVariable($varName, $path, "User"); + } else { + . "$PSScriptRoot/../aliae/Manage.ps1"; + Add-EnvironmentVariable -User $Arguments.Name $varName $path; + } + } }; diff --git a/scripts/Windows/Software/Oh My Posh/Manage.ps1 b/scripts/Windows/Software/Oh My Posh/Manage.ps1 index 19a58f49..47784d60 100644 --- a/scripts/Windows/Software/Oh My Posh/Manage.ps1 +++ b/scripts/Windows/Software/Oh My Posh/Manage.ps1 @@ -6,15 +6,18 @@ param ( . "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; . "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1"; -Start-SoftwareInstaller @PSBoundParameters ` - -Installer { - param( - [scriptblock] $Installer - ) +& { + param($Parameters) + $base = "$PSScriptRoot/../../../Common/Software/Oh My Posh/Manage.ps1"; - Install-WingetPackage JanDeDobbeleer.OhMyPosh -ArgumentList "--scope","machine"; - } ` - -Configurator { - . "$PSScriptRoot/../../../Common/Software/Oh My Posh/Manage.ps1" ` - -Action ([InstallerAction]::Configure); - }; + Start-SoftwareInstaller @Parameters ` + -Installer { + Install-WingetPackage JanDeDobbeleer.OhMyPosh -ArgumentList "--scope","machine"; + } ` + -Configurator { + . $base -Action ([InstallerAction]::Configure); + } ` + -UserConfigurator { + . $base -Action ([InstallerAction]::ConfigureUser); + }; +} $PSBoundParameters;