From d3dcddab0875c951e46b9f5b0a017dd4d467ca4a 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 | 45 ++++++++++++---------- 3 files changed, 45 insertions(+), 21 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..c365cb40 --- /dev/null +++ b/scripts/Common/Software/zoxide/Main.ps1 @@ -0,0 +1,19 @@ +param( + $Action, + [hashtable] $Arguments +) + +. "$PSScriptRoot/../../Scripts/Software.ps1"; +. "$PSScriptRoot/../PowerShell/Profile.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 3ce6998f..5c385e85 100644 --- a/scripts/Windows/Software/zoxide/Manage.ps1 +++ b/scripts/Windows/Software/zoxide/Manage.ps1 @@ -3,25 +3,30 @@ param( [hashtable] $Arguments ) -. "$PSScriptRoot/../../../Common/Software/PowerShell/Profile.ps1"; -. "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; +& { + param( + [hashtable] $Parameters + ) -Start-SoftwareInstaller @PSBoundParameters ` - -Installer { - param( - [scriptblock] $Installer - ) + . "$PSScriptRoot/../../../Common/Software/PowerShell/Profile.ps1"; + . "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; + . "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1"; + $base = "$PSScriptRoot/../../../Common/Software/zoxide/Main.ps1"; - 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); - }; + Start-SoftwareInstaller @PSBoundParameters ` + -Installer { + param( + [scriptblock] $Installer + ) + + Install-ChocoPackage zoxide; + Install-WingetPackage junegunn.fzf; + } ` + -Configurator { + param( + $Arguments + ) + + & $base ([InstallerAction]::ConfigureUser) @PSBoundParameters; + }; +} $PSBoundParameters;