From 0c4d4de04112b1f48a29bb6a1f31efd892b25dbd Mon Sep 17 00:00:00 2001 From: Fabio Scotto di Santolo Date: Thu, 2 Jan 2025 19:50:02 +0100 Subject: [PATCH] Fix CommandNotFound check OS --- .../.config/powershell/Microsoft.PowerShell_profile.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/powershell/.config/powershell/Microsoft.PowerShell_profile.ps1 b/powershell/.config/powershell/Microsoft.PowerShell_profile.ps1 index d3759a3..ca59846 100644 --- a/powershell/.config/powershell/Microsoft.PowerShell_profile.ps1 +++ b/powershell/.config/powershell/Microsoft.PowerShell_profile.ps1 @@ -296,7 +296,14 @@ if (Get-Command zoxide -ErrorAction SilentlyContinue) { Set-Alias -Name z -Value __zoxide_z -Option AllScope -Scope Global -Force Set-Alias -Name zi -Value __zoxide_zi -Option AllScope -Scope Global -Force -#Import-Module -Name Microsoft.WinGet.CommandNotFound +$isWin = $PSVersionTable.OS -match "Windows" +if (-not (Get-Module -ListAvailable -Name Microsoft.WinGet.CommandNotFound) -and $isWin) { + Install-Module -Name Microsoft.WinGet.CommandNotFound -Scope CurrentUser -Force -SkipPublisherCheck +} + +if ($isWin) { + Import-Module -Name Microsoft.WinGet.CommandNotFound +} # Import Modules and External Profiles # Ensure Terminal-Icons module is installed before importing