mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-17 18:27:42 -06:00
Able to set the Default Terminal to Powershell 7 in Windows Terminal
* Run winget in open powershell window if possible and handle update * add return code reference * Seperated Logic for PS7 Profile change * Add tweak * Revert changes to last commit in Christitus Repo * Merge pull request #1 from Marterich/PS7profile Split Logic in different Script, Re-Add files with to reflect Chris's Repo
This commit is contained in:
parent
dfcf4cb8eb
commit
8a10e59aa8
@ -2336,6 +2336,19 @@
|
|||||||
"
|
"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"WPFTweaksPowershell7": {
|
||||||
|
"Content": "Replace Default Powershell 5 to Powershell 7",
|
||||||
|
"Description": "This will edit the config file of the Windows Terminal Replacing the Powershell 5 to Powershell 7 and install Powershell 7 if necessary",
|
||||||
|
"category": "Essential Tweaks",
|
||||||
|
"panel": "1",
|
||||||
|
"Order": "a007_",
|
||||||
|
"InvokeScript": [
|
||||||
|
"Invoke-WPFTweakPS7 -action \"PS7\""
|
||||||
|
],
|
||||||
|
"UndoScript": [
|
||||||
|
"Invoke-WPFTweakPS7 -action \"PS5\""
|
||||||
|
]
|
||||||
|
},
|
||||||
"WPFTweaksOO": {
|
"WPFTweaksOO": {
|
||||||
"Content": "Run OO Shutup",
|
"Content": "Run OO Shutup",
|
||||||
"Description": "Runs OO Shutup and applies the recommended Tweaks. https://www.oo-software.com/en/shutup10",
|
"Description": "Runs OO Shutup and applies the recommended Tweaks. https://www.oo-software.com/en/shutup10",
|
||||||
@ -3083,4 +3096,4 @@
|
|||||||
"Order": "a082_",
|
"Order": "a082_",
|
||||||
"Type": "300"
|
"Type": "300"
|
||||||
}
|
}
|
||||||
}
|
}
|
46
functions/public/Invoke-WPFTweakPS7.ps1
Normal file
46
functions/public/Invoke-WPFTweakPS7.ps1
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
function Invoke-WPFTweakPS7{
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
This will edit the config file of the Windows Terminal Replacing the Powershell 5 to Powershell 7 and install Powershell 7 if necessary
|
||||||
|
.PARAMETER action
|
||||||
|
PS7: Configures Powershell 7 to be the default Terminal
|
||||||
|
PS5: Configures Powershell 5 to be the default Terminal
|
||||||
|
#>
|
||||||
|
param (
|
||||||
|
[ValidateSet("PS7", "PS5")]
|
||||||
|
[string]$action
|
||||||
|
)
|
||||||
|
|
||||||
|
switch ($action) {
|
||||||
|
"PS7"{
|
||||||
|
if (Test-Path -Path "$env:ProgramFiles\PowerShell\7") {
|
||||||
|
Write-Host "Powershell 7 is already installed."
|
||||||
|
} else {
|
||||||
|
Write-Host "Installing Powershell 7..."
|
||||||
|
Install-WinUtilProgramWinget -ProgramsToInstall @(@{"winget"="Microsoft.PowerShell"})
|
||||||
|
}
|
||||||
|
$targetTerminalName = "PowerShell"
|
||||||
|
}
|
||||||
|
"PS5"{
|
||||||
|
$targetTerminalName = "Windows PowerShell"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$settingsPath = "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json"
|
||||||
|
if (Test-Path -Path $settingsPath) {
|
||||||
|
Write-Host "Settings file found."
|
||||||
|
$settingsContent = Get-Content -Path $settingsPath | ConvertFrom-Json
|
||||||
|
$ps7Profile = $settingsContent.profiles.list | Where-Object { $_.name -eq $targetTerminalName }
|
||||||
|
if ($ps7Profile) {
|
||||||
|
$settingsContent.defaultProfile = $ps7Profile.guid
|
||||||
|
$updatedSettings = $settingsContent | ConvertTo-Json -Depth 100
|
||||||
|
Set-Content -Path $settingsPath -Value $updatedSettings
|
||||||
|
Write-Host "Default profile updated to $targetTerminalName using the name attribute."
|
||||||
|
} else {
|
||||||
|
Write-Host "No PowerShell 7 profile found in Windows Terminal settings using the name attribute."
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host "Settings file not found at $settingsPath"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user