Install posh theme automatically

This commit is contained in:
Manuel Thalmann 2024-08-23 23:53:48 +02:00
parent 0ad9e94a1f
commit ab4b6dc63c
2 changed files with 41 additions and 11 deletions

View file

@ -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;
}
}
};

View file

@ -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;