0

I would like to add some profile entries to the Windows Terminal profiles.json file.

This is my current profiles.json file:

{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",

    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles
        },
        "list":
        [
            {
                // Make changes here to the powershell.exe profile
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false
            },
            {
                // Make changes here to the cmd.exe profile
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "cmd",
                "commandline": "cmd.exe",
                "hidden": false
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            }
        ]
    },

    "schemes": [],

    "keybindings": []
}

And I would like to add this for example into the "list" array:

{
    "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff85ed}",
    "name": "Git Bash",
    "commandline": "git-bash.exe",
    "hidden": false
}

This is my current dummy code:

var profilesFile = Path.Combine(
    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\profiles.json");

var options = new JsonSerializerOptions();
options.ReadCommentHandling = JsonCommentHandling.Skip;
var myObj = JsonSerializer.Deserialize<dynamic>(File.ReadAllBytes(profilesFile), options);

But I don't know if I'm on the right road.

0lan
  • 101
  • 6

0 Answers0