ChrisTitusTech / winutil

Chris Titus Tech's Windows Utility - Install Programs, Tweaks, Fixes, and Updates
MIT License
24.59k stars 1.49k forks source link

Fix: Correct Windows Terminal default profile path to PowerShell 7 #3032

Closed Anmol-sudo closed 1 day ago

Anmol-sudo commented 1 week ago

Type of Change

Description

This pull request addresses an issue with the Windows Terminal configuration in the Invoke-WPFTweakPS7 function. Previously, the function was unable to correctly locate or interact with the PowerShell 7 installation due to an incorrect path.

The changes include:

  1. Updated the path in Invoke-WPFTweakPS7.ps1 to correctly locate the PowerShell 7 installation.
  2. Improved the logic for setting the default profile in Windows Terminal settings.
  3. Enhanced error handling and user feedback for cases where Windows Terminal or its settings file are not found.

These modifications ensure proper functionality of PowerShell 7 related tweaks and improve the reliability of PowerShell 7 operations in the winutil script.

Testing

I have tested these changes by:

  1. Running the script on a clean Windows installation.
  2. Verifying that PowerShell 7 is correctly set as the default profile in Windows Terminal after running the tweak.
  3. Ensuring that the script gracefully handles scenarios where Windows Terminal is not installed or the settings file is not found.
  4. Checking that the script can still set PowerShell 5 as the default when requested.

Impact

This fix will improve the user experience for those using the PowerShell 7 tweak, ensuring that their Windows Terminal is correctly configured. It also adds robustness to the script by improving error handling.

Additional Information

This change does not introduce any new dependencies and should be backwards compatible with existing setups.

Checklist

image

error-img

Cryostrixx commented 1 week ago

Hello, @Anmol-sudo! Thanks for the report, but just to give you a heads-up both PowerShell 5 and PowerShell 7 are on the path by default, it is not necessary to hardcode the paths as their respective entries are added when installed (see attached screenshot): image

Additionally, this happens if you set PowerShell 7 as the default for Windows Terminal and then uninstall PowerShell 7 using a program like BCUninstaller, as uninstalling PowerShell 7 would remove it from your path, even if the path entry for it remains. Can you please run Get-Command powershell and Get-Command pwsh in PowerShell 5 and share the results?

Anmol-sudo commented 1 week ago

image After using this feature in winutil image

Winutil sets the command line path for powershell7 in strings in windows terminal image which is wrong, the correct command line pathshould be without strings. image So i fixed it

Cryostrixx commented 1 week ago

image In Windows Terminal winutil sets the path like this for powershell7 image which is wrong, the correct should be without strings. image So i fixed it

I'm glad you fixed it on your own! If the fix you proposed works as intended, just be patient, and eventually, someone will test and approve it.

Anmol-sudo commented 1 week ago

Thanks

Cryostrixx commented 1 week ago

Thanks, I think the ctrl+shift+3 is the Windows terminal problem not the winutil problem, u can reset the terminal tho

It's more on me than anything else, I won't report it as it's caused by user error, I am fixing that now, this PR should remain focused on the initial topic.