How to safely update Terminal's config file with PSWinTerminal? #9962

Closed
opened 2026-01-31 02:08:36 +00:00 by claunia · 3 comments
Owner

Originally created by @sassdawe on GitHub (Aug 1, 2020).

Description of the new feature/enhancement

What is the safest way to update Terminal's config file from a command line running inside the Terminal?

I'd like to avoid colliding with your future feature updates.

Proposed technical implementation details (optional)

I published PSWinTerminal into PowerShell Gallery, which implements Get-WTTheme, Show-WTTheme, and Set-WTTheme.

And I'm planning to implement Import-WTTheme / New-WTTheme to extend the available themes.

How should I approach these cmdlets without risking breaking the configuration? Thanks!

Originally created by @sassdawe on GitHub (Aug 1, 2020). # Description of the new feature/enhancement What is the safest way to update Terminal's config file from a command line running inside the Terminal? **I'd like to avoid colliding with your future feature updates.** # Proposed technical implementation details (optional) I published [PSWinTerminal](https://www.powershellgallery.com/packages/PSWinTerminal/) into PowerShell Gallery, which implements Get-WTTheme, Show-WTTheme, and Set-WTTheme. And I'm planning to implement Import-WTTheme / New-WTTheme to extend the available themes. How should I approach these cmdlets without risking breaking the configuration? Thanks!
claunia added the Issue-QuestionNeeds-Tag-FixResolution-Answered labels 2026-01-31 02:08:36 +00:00
Author
Owner

@sassdawe commented on GitHub (Aug 1, 2020):

You can see my implementation of PSWinTerminal here

I used the available environment variables, and I have some ideas for new variables. Should I open an other issues to cover those?

@sassdawe commented on GitHub (Aug 1, 2020): You can see my implementation of [PSWinTerminal here](https://github.com/sassdawe/PSWinTerminal/blob/main/PSWinTerminal.psm1) I used the available environment variables, and I have some ideas for new variables. Should I open an other issues to cover those?
Author
Owner

@DHowett commented on GitHub (Aug 21, 2020):

@sassdawe Sorry to let this issue languish on our repo for so long. As somebody building on top of Terminal you almost certainly deserve better than that!

So, here's the deal.

Detecting where the settings are

Right now, we're leaving this largely up to chance. The user's settings will be in one of three (or four, if they're a terminal developer) places, and figuring out exactly which one is active is hard. We had a proposal, #4566, that would get us there. We need to have out the discussion in that one on whether we really do think it a good idea.

Editing settings safely

There's another project, MSTerminalSettings, that now uses C# code automatically generated from our settings schema. If it's possible for you to follow our schema in a similar way--I'm not sure what powershell offers in terms of JSON schema support--that would make certain that you're not breaking anything.

Otherwise, it's entirely safe to edit the user's settings and re-save them. It's a minor pain because we're "mostly JSON" with the addition of trailing commas and comments... much to the ire of some of the more steadfast JSON supporters in our community.

future

We're actively working to separate our settings model -- serializers and deserializers and all -- out into a separate component library that can operate independent of Terminal. One of our goals is to make it easier for people to edit our settings through a programmatic interface. You can follow the progress of that one in #885/#7141

@DHowett commented on GitHub (Aug 21, 2020): @sassdawe Sorry to let this issue languish on our repo for so long. As somebody building on top of Terminal you almost certainly deserve better than that! So, here's the deal. ### Detecting where the settings are Right now, we're leaving this largely up to chance. The user's settings will be in one of three (or four, if they're a terminal developer) places, and figuring out exactly which one is active is _hard_. We had a proposal, #4566, that would get us there. We need to have out the discussion in that one on whether we really do think it a good idea. ### Editing settings safely There's another project, MSTerminalSettings, that now uses C# code automatically generated from our [settings schema](https://aka.ms/terminal-profiles-schema). If it's possible for you to follow our schema in a similar way--I'm not sure what powershell offers in terms of JSON schema support--that would make certain that you're not breaking anything. Otherwise, it's **entirely safe** to edit the user's settings and re-save them. It's a minor pain because we're "mostly JSON" with the addition of trailing commas and comments... much to the ire of some of the more steadfast JSON supporters in our community. ### future We're actively working to separate our settings model -- serializers and deserializers and all -- out into a separate component library that can operate independent of Terminal. One of our goals is to make it easier for people to edit our settings through a programmatic interface. You can follow the progress of that one in #885/#7141
Author
Owner

@DHowett commented on GitHub (Aug 21, 2020):

By the way, it's really nice to see folks writing modules that support all the weird stuff we do here. You're very much appreciated 😄

@DHowett commented on GitHub (Aug 21, 2020): By the way, it's really nice to see folks writing modules that support all the weird stuff we do here. You're very much appreciated :smile:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9962