2024-08-07 21:22:04 +00:00
|
|
|
param (
|
|
|
|
$Action,
|
|
|
|
[hashtable] $Arguments
|
|
|
|
)
|
|
|
|
|
2024-08-23 21:53:48 +00:00
|
|
|
. "$PSScriptRoot/../aliae/Manage.ps1";
|
2024-08-07 21:22:04 +00:00
|
|
|
. "$PSScriptRoot/../PowerShell/Profile.ps1";
|
|
|
|
. "$PSScriptRoot/../../Scripts/Software.ps1";
|
|
|
|
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
|
|
|
|
|
|
|
|
Start-SoftwareInstaller @PSBoundParameters `
|
|
|
|
-Configurator {
|
2024-09-23 00:10:42 +00:00
|
|
|
param([string] $Name)
|
|
|
|
|
2024-08-07 21:22:04 +00:00
|
|
|
Add-PowerShellProfileStatement `
|
|
|
|
-System `
|
2024-09-23 00:10:42 +00:00
|
|
|
-Category "$Name" `
|
2024-08-07 21:22:04 +00:00
|
|
|
-Script (
|
|
|
|
@(
|
|
|
|
"# Oh My Posh!",
|
|
|
|
(Get-ScriptInitializer "oh-my-posh init pwsh"),
|
|
|
|
(Get-ScriptInitializer "oh-my-posh completion powershell")
|
|
|
|
) -join [System.Environment]::NewLine)
|
2024-08-23 21:53:48 +00:00
|
|
|
} `
|
|
|
|
-UserConfigurator {
|
|
|
|
param(
|
|
|
|
[hashtable] $Arguments
|
|
|
|
)
|
|
|
|
|
|
|
|
$theme = Get-UserConfig "oh-my-posh.theme";
|
|
|
|
|
2024-09-22 22:10:05 +00:00
|
|
|
function New-Theme {
|
|
|
|
param($info)
|
|
|
|
$root = "$($IsWindows ? $env:AppData : "~/.config")/oh-my-posh";
|
|
|
|
$path = Join-Path $root "$($info.name).omp.json";
|
|
|
|
$null = New-Item -Force -ItemType Directory $root;
|
|
|
|
|
|
|
|
Set-Content $path (
|
|
|
|
& {
|
|
|
|
if ($IsWindows) {
|
|
|
|
wsl cat $info.source;
|
|
|
|
} else {
|
|
|
|
cat $info.source;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return $path;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($additionalTheme in (Get-UserConfig "oh-my-posh.additionalThemes")) {
|
|
|
|
Write-Host "creating theme $additionalTheme"
|
|
|
|
$null = New-Theme $additionalTheme;
|
|
|
|
}
|
|
|
|
|
2024-08-23 21:53:48 +00:00
|
|
|
if ($theme) {
|
|
|
|
$varName = "POSH_THEME";
|
|
|
|
|
|
|
|
if ($theme -isnot [string]) {
|
2024-09-22 22:10:05 +00:00
|
|
|
$theme = [string](New-Theme $theme);
|
2024-08-23 21:53:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($IsWindows) {
|
2024-09-22 22:10:05 +00:00
|
|
|
[System.Environment]::SetEnvironmentVariable($varName, "%AppData%/$([System.IO.Path]::GetRelativePath($env:AppData, $theme))", "User");
|
2024-08-23 21:53:48 +00:00
|
|
|
} else {
|
|
|
|
. "$PSScriptRoot/../aliae/Manage.ps1";
|
2024-09-22 22:10:05 +00:00
|
|
|
Add-EnvironmentVariable -User $Arguments.Name $varName ($theme).Replace("~", "{{ .Home }}");
|
2024-08-23 21:53:48 +00:00
|
|
|
}
|
|
|
|
}
|
2024-08-07 21:22:04 +00:00
|
|
|
};
|