Add Windows 10 only profile to PowerShell profile

This commit is contained in:
shenjack 2024-01-18 00:18:36 +08:00
parent 0832da5147
commit 6caedc71dc
Signed by: shenjack
GPG Key ID: 7B1134A979775551

View File

@ -46,6 +46,16 @@ if ($IsWindows) {
# Windows 下的 vcpkg 初始化 # Windows 下的 vcpkg 初始化
Import-Module 'V:\githubs\vcpkg\scripts\posh-vcpkg' Import-Module 'V:\githubs\vcpkg\scripts\posh-vcpkg'
# Windows 10 only
$is_windows_10 = [System.Environment]::OSVersion.Version.Major -eq "10"
if ($is_windows_10) {
# https://github.com/PowerShell/PowerShell/issues/13138
# 其实就是 patch 成 import-module appx -usewindowspowershell
$PSDefaultParameterValues['Import-Module:UseWindowsPowerShell'] = {
if ((Get-PSCallStack)[1].Position.Text -match '\bAppX\b') { $true }
}
Write-Host "loaded Windows 10 only profile"
}
Write-Host "loaded Windows only profile" Write-Host "loaded Windows only profile"
} }