From 4eab5617b3edfe8702254eafee5966ff226825a7 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 20 Mar 2024 21:34:47 +0100 Subject: [PATCH] Create common `pwsh` installation script --- scripts/Common/Config/Oh My Posh/install.ps1 | 12 ++++++++++++ scripts/Windows/Config/Oh My Posh/Install.ps1 | 17 ----------------- scripts/Windows/Software/Oh My Posh/Install.ps1 | 2 +- 3 files changed, 13 insertions(+), 18 deletions(-) create mode 100644 scripts/Common/Config/Oh My Posh/install.ps1 delete mode 100644 scripts/Windows/Config/Oh My Posh/Install.ps1 diff --git a/scripts/Common/Config/Oh My Posh/install.ps1 b/scripts/Common/Config/Oh My Posh/install.ps1 new file mode 100644 index 00000000..d753061f --- /dev/null +++ b/scripts/Common/Config/Oh My Posh/install.ps1 @@ -0,0 +1,12 @@ +#!/bin/pwsh +. "$PSScriptRoot/../powershell/lib.ps1"; + +Add-PowerShellProfileStatement ` + -Category "oh-my-posh" ` + -Statement $( + @( + "# Oh My Posh!", + $(Get-ScriptInitializer "oh-my-posh init pwsh"), + $(Get-ScriptInitializer "oh-my-posh completion powershell") + ) -join [System.Environment]::NewLine + ) diff --git a/scripts/Windows/Config/Oh My Posh/Install.ps1 b/scripts/Windows/Config/Oh My Posh/Install.ps1 deleted file mode 100644 index 6b820b7a..00000000 --- a/scripts/Windows/Config/Oh My Posh/Install.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/pwsh -param($context) -. "$PSScriptRoot/../../Scripts/Context.ps1"; - -[Context] $context = $context; -Write-Host "Configuring Oh My Posh!"; - -$createInvokation = { - param($initializer) - return ". ([scriptblock]::Create(($initializer) -join `"``n`"))"; -} - -$context.AddPowerShellProfileStatement( - "999_Oh My Posh", - [string[]]@( - $createInvokation.Invoke("oh-my-posh init pwsh"), - $createInvokation.Invoke("oh-my-posh completion powershell")) -join [System.Environment]::NewLine); diff --git a/scripts/Windows/Software/Oh My Posh/Install.ps1 b/scripts/Windows/Software/Oh My Posh/Install.ps1 index 268a4db5..e85a482f 100644 --- a/scripts/Windows/Software/Oh My Posh/Install.ps1 +++ b/scripts/Windows/Software/Oh My Posh/Install.ps1 @@ -4,4 +4,4 @@ param($context); [Context] $context = $context; winget install --accept-source-agreements --accept-package-agreements -s winget --scope machine -e --id JanDeDobbeleer.OhMyPosh; -. "$PSScriptRoot/../../Config/Oh My Posh/Install.ps1" $context; +. "$PSScriptRoot/../../../Common/Config/Oh My Posh/install.ps1";