Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Anmol-sudo
Copy link

Type of Change

  • Bug fix

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

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no errors/warnings/merge conflicts.

image

error-img

@Anmol-sudo Anmol-sudo changed the title Title: Fix: Correct Windows Terminal default profile path to PowerShell 7 Fix: Correct Windows Terminal default profile path to PowerShell 7 Nov 10, 2024
@Cryostrixx
Copy link
Contributor

Cryostrixx commented Nov 10, 2024

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
Copy link
Author

Anmol-sudo commented Nov 11, 2024

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
Copy link
Contributor

Cryostrixx commented Nov 11, 2024

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
Copy link
Author

Anmol-sudo commented Nov 11, 2024

Thanks

@Cryostrixx
Copy link
Contributor

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.

Copy link
Owner

@ChrisTitusTech ChrisTitusTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path is incorrect this should use $env:HOMEDRIVE instead of C:

This ensures it will work on non-standard installs where C: isn't the home drive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants