Windows Terminal has a feature known as JSON Fragment Extensions for developers to add additional profiles without needing to directly modify the settings.json
.
The hardest part is creating the correct GUID for your profile name -- I'm not 100% sure on the process myself, having not tried it personally, but at least there is sample Python code on that page for that. Once you determine the profile's GUID, you can hardcode it -- No need to do it programmatically during installation.
Since it doesn't sound like you are developing a Store app, you'd likely be considered an "app installed from the web" for the purposes of where to place the fragment. You can either put it in C:\ProgramData\Microsoft\Windows Terminal\Fragments\{app-name}\{file-name}.json
for all users on the system or C:\Users\<user>\AppData\Local\Microsoft\Windows Terminal\Fragments\{app-name}\{file-name}.json
for individual users.
Note that since you say you will be using PowerShell for the installation, the doc mentions that you must use UTF-8 encoding (E.g. Out-File $fragmentPath -Encoding Utf8
).
If you'd like to see some examples of real, working JSON fragments, the following applications that I'm aware of utilize the feature:
- Git Bash
- Ubuntu 22.04 for WSL
You can find the Ubuntu one (and possible some others) by starting an Administrative PowerShell and running:
Get-ChildItem -Recurse 'C:\Program Files\WindowsApps\' | Where-Object {$_.Name -like 'terminal.json' }