From b31d25ea3af23590f97429f3016da574c5888ab6 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 19 Sep 2024 22:24:36 +0200 Subject: [PATCH] Make `zoxide` installation cross platform --- scripts/Common/Software/zoxide/Main.ps1 | 19 +++++++++++ scripts/Common/Software/zoxide/main.fish | 2 +- scripts/Windows/Software/zoxide/Manage.ps1 | 39 ++++++++++++---------- 3 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 scripts/Common/Software/zoxide/Main.ps1 diff --git a/scripts/Common/Software/zoxide/Main.ps1 b/scripts/Common/Software/zoxide/Main.ps1 new file mode 100644 index 00000000..ce91049f --- /dev/null +++ b/scripts/Common/Software/zoxide/Main.ps1 @@ -0,0 +1,19 @@ +param( + $Action, + [hashtable] $Arguments +) + +. "$PSScriptRoot/../PowerShell/Profile.ps1"; +. "$PSScriptRoot/../../Scripts/Software.ps1"; + +Start-SoftwareInstaller @PSBoundParameters ` + -Configurator { + Add-PowerShellProfileStatement ` + -System ` + -Category "zoxide" ` + -Script ( + @( + "# zoxide", + (Get-ScriptInitializer "zoxide init powershell | Out-String") + ) -join [System.Environment]::NewLine); + }; diff --git a/scripts/Common/Software/zoxide/main.fish b/scripts/Common/Software/zoxide/main.fish index 5d0c64be..210114cb 100755 --- a/scripts/Common/Software/zoxide/main.fish +++ b/scripts/Common/Software/zoxide/main.fish @@ -8,7 +8,7 @@ begin source "$dir/../fish/profile.fish" echo 'eval "$(zoxide init bash)"' | installBashProfile "zoxide" echo "zoxide init fish | source" | installFishProfile "zoxide" - sudo pwsh -NoProfile "$dir/install.ps1" + sudo -HE pwsh -NoProfile "$dir/Main.ps1" Configure end runInstaller $argv diff --git a/scripts/Windows/Software/zoxide/Manage.ps1 b/scripts/Windows/Software/zoxide/Manage.ps1 index 89f0c13b..07d5eb99 100644 --- a/scripts/Windows/Software/zoxide/Manage.ps1 +++ b/scripts/Windows/Software/zoxide/Manage.ps1 @@ -3,21 +3,26 @@ param( [hashtable] $Arguments ) -. "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; -. "$PSScriptRoot/../../../Common/Software/PowerShell/Profile.ps1"; +& { + param( + [hashtable] $Parameters + ) -Start-SoftwareInstaller @PSBoundParameters ` - -Installer { - Install-ChocoPackage zoxide; - Install-WingetPackage junegunn.fzf; - } ` - -Configurator { - Add-PowerShellProfileStatement ` - -System ` - -Category "zoxide" ` - -Script ( - @( - "# zoxide", - (Get-ScriptInitializer "zoxide init powershell | Out-String") - ) -join [System.Environment]::NewLine); - }; + . "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; + . "$PSScriptRoot/../../../Common/Software/PowerShell/Profile.ps1"; + . "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1"; + $base = "$PSScriptRoot/../../../Common/Software/zoxide/Main.ps1"; + + Start-SoftwareInstaller @PSBoundParameters ` + -Installer { + Install-ChocoPackage zoxide; + Install-WingetPackage junegunn.fzf; + } ` + -Configurator { + param( + $Arguments + ) + + & $base ([InstallerAction]::Configure) @PSBoundParameters; + }; +} $PSBoundParameters;