Terminal: Using different GUIDs for profiles that use "source" cause them to not be found by Terminal.

Created on 23 Apr 2020  Â·  6Comments  Â·  Source: microsoft/terminal

Environment

Windows build number: Version 10.0.18363.778
Windows Terminal version: 0.11
Any other software? No

Steps to reproduce

  • Open Terminal, let it create a new, default configuration file (settings.json).
  • Make the PowerShell Core the default profile: {574e775e-4f2a-5b96-ac1e-a2962a402336}

    • This will work, Terminal will now launch with PowerShell Core as default profile.

  • Go to profiles section, change any value in the PowerShell Core profile's GUID and make this new GUID the default profile.

    • This will cause the PowerShell Core profile with the changed GUID to be ignored, causing:

    • A new PowerShell Core profile with the original GUID being added to the end of the profiles list

    • The default profile (changed PowerShell Core GUID) to be invalid as Terminal can now no longer read the old PowerShell Core profile.

    • The old profile with the changed GUID no longer appears in the list of profiles.

This is only true for all the profiles using a "source" instead of a "commandline" parameter to start the shell.

Expected behavior

Terminal accepts any vaild GUID for any type of profile and starts or lists it in the list of profiles OR clearly documents that profiles need to have a specific GUID.

Actual behavior

  • This will cause the PowerShell Core profile with the changed GUID to be ignored, causing:

    • A new PowerShell Core profile with the original GUID being added to the end of the profiles list

    • The default profile (changed PowerShell Core GUID) to be invalid as Terminal can now no longer read the old PowerShell Core profile.

Area-Settings Issue-Question Product-Terminal Resolution-Answered Resolution-By-Design

Most helpful comment

I’ll make sure our documentation’s clearer about sources and how to deal with dynamic profiles while we don’t have a setting UI. Thanks a bunch :)

All 6 comments

Same here! After the update my Ubuntu profile wasn't the default anymore (even with the correct guid on defaultProfile property).

Thanks to @TechPreacher for highlighting the source/commandline thing, it did the trick for me (for now).

For those looking for a quick local fix:

Current (and stock) settings that can't be set as default:

{
   "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
   "hidden": false,
   "name": "Ubuntu",
   "source": "Windows.Terminal.Wsl"
},

Fixed:

{
   "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
   "hidden": false,
   "name": "Ubuntu",
   "source": "wsl.exe -d Ubuntu",
},

p.s: I'm not running any insider build, I'm assuming these changes might need to be reverted once we have the 2004 build.

That’s not what source does, and is absolutely not going to improve your situation. Source is an indicator as to which component of Terminal _created_ the profile. That component, which we call the “generator,” sets various properties like the command line and name and color scheme for you to override.

Switching the GUID of a profile that has a generator will make it so the generator _cannot find the existing profile_ and has to make a new one with different settings.

Switching up the guid and keeping the source field will also make your profile disappear: Terminal believes that it was automatically generated and because the generator can’t attest to its existence, it’s assumed that _it no longer exists_. (This is how old WSL distributions disappear from your profile list even though they’re still in your settings file with your customizations saved.)

If your defaultProfile stopped working, you probably want #5458.

Now that I'm at my computer (sorry: prior message was terse because it was written on my phone)...

So, this deserves some real documentation. Here's the deal:

  • Terminal wants to maintain lists of things -- WSL distributions, powershell installations -- so that it can delete the ones that no longer exist. If you uninstall Ubuntu, we don't want to leave an Ubuntu profile in your menu.

    • We can't delete it from your settings file. If you reinstall Ubuntu, we want your customizations to remain intact.

  • source and guid are parts of the primary key that Terminal uses to determine which profiles were created by our application.
  • If a profile has a guid and a source, terminal thinks that it created this profile.
  • When we start up, we ask each generator (whose name is specified by source) for a list of profiles.
  • Every profile that DOES NOT APPEAR in the generator's output is hidden (see above)

    • This means that if you add a _new_ profile that has both a source and a guid, and that generator does not agree with you, that profile will just be hidden. This is the bug report, and this is by design.

  • Every profile that appears in the generator's output but NOT in the user's settings gets a newly-allocated profile block inserted into the user's settings.

    • This is so the user has a landing zone to customize the new profile.

This will be cleared up with the settings UI (#1564) and profile inheritance (#3818, so you don't need to edit the existing profile as much or try to make a copy of it.)

@DHowett-MSFT thanks for clarifying. It makes complete sense, it was just under-documented, or I didn't find it. In my old settings I had all my profiles with "commandline" and saw that it also works - much cleaner in my opinion - with "source". That's why I took my old profiles that had a some customization (titles, icons etc.) and replaced "commandline" with "source", which is where the trouble started. I now use all the default profiles that use "source" and just keep my custom made one for Git Bash around, which works perfectly.

// This file was initially generated by Windows Terminal 0.11.1121.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",

    // You can add more global application settings here.
    // To learn more about global settings, visit https://aka.ms/terminal-global-settings

    // If enabled, selections are automatically copied to your clipboard.
    "copyOnSelect": false,

    // If enabled, formatted data is also copied to your clipboard
    "copyFormatting": true,

    // Initial positioning and size (Sascha)
    "initialCols" : 120,
    "initialRows" : 50,
    "initialPosition" : "10, 10",

    // A profile specifies a command to execute paired with information about how it should look and feel.
    // Each one of them will appear in the 'New Tab' dropdown,
    //   and can be invoked from the commandline with `wt.exe -p xxx`
    // To learn more about profiles, visit https://aka.ms/terminal-profile-settings
    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles.
            "acrylicOpacity" : 0.75,
            "background" : "#000000",
            "backgroundImageOpacity" : 0.5,
            "colorScheme" : "Dracula",
            "fontFace" : "Fira Code",
            "fontSize" : 10,
            "padding" : "3, 3, 3, 3",
            "useAcrylic" : true
        },
        "list":
        [
            {
                // Powershell Core
                "backgroundImage" : "C:/Users/saschac/OneDrive/Microsoft Terminal/br1.jpg",
                "guid" : "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "icon" : "C:/Users/saschac/OneDrive/Microsoft Terminal/Powershell_av_colors.ico",
                "name" : "PowerShell Core",
                "source": "Windows.Terminal.PowershellCore"
            },
            {
                // Powershell
                "backgroundImage" : "C:/Users/saschac/OneDrive/Microsoft Terminal/br1.jpg",
                "commandline" : "powershell.exe",
                "guid" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": false,
                "icon" : "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
                "name" : "PowerShell"
            },
            {
                // Command Prompt
                "backgroundImage" : "C:/Users/saschac/OneDrive/Microsoft Terminal/br2.jpg",
                "commandline" : "cmd.exe",
                "guid" : "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": false,
                "icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
                "name" : "Command Prompt"
            },
            {
                // WSL Ubuntu
                "backgroundImage" : "C:/Users/saschac/OneDrive/Microsoft Terminal/br3.jpg",
                "guid" : "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "hidden": false,
                "icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
                "name" : "WSL Ubuntu",
                "source": "Windows.Terminal.Wsl"
            },
            {
                // Git Bash
                "backgroundImage" : "C:/Users/saschac/OneDrive/Microsoft Terminal/br3.jpg",
                "commandline" : "\"%PROGRAMFILES%\\git\\bin\\bash.exe\" --login -i -l",
                "hidden": false,
                "guid" : "{3acde342-38b7-51cf-b940-2309a097f518}",
                "icon" : "C:/Users/saschac/OneDrive/Microsoft Terminal/git-for-windows.ico",
                "name" : "Git Bash"
            },
            {
                // Azure Cloud Shell
                "backgroundImage" : "C:/Users/saschac/OneDrive/Microsoft Terminal/br1.jpg",
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "icon" : "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            }
        ]
    },

    // Add custom color schemes to this array.
    // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
    "schemes": 
    [
        {
            "name" : "Dracula",
            "background" : "#282A36",
            "black" : "#21222C",
            "blue" : "#BD93F9",
            "brightBlack" : "#6272A4",
            "brightBlue" : "#D6ACFF",
            "brightCyan" : "#A4FFFF",
            "brightGreen" : "#69FF94",
            "brightPurple" : "#FF92DF",
            "brightRed" : "#FF6E6E",
            "brightWhite" : "#FFFFFF",
            "brightYellow" : "#FFFFA5",
            "cyan" : "#8BE9FD",
            "foreground" : "#F8F8F2",
            "green" : "#50FA7B",
            "purple" : "#FF79C6",
            "red" : "#FF5555",
            "white" : "#F8F8F2",
            "yellow" : "#F1FA8C"
        }
    ],

    // Add custom keybindings to this array.
    // To unbind a key combination from your defaults.json, set the command to "unbound".
    // To learn more about keybindings, visit https://aka.ms/terminal-keybindings
    "keybindings":
    [
        // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
        // These two lines additionally bind them to Ctrl+C and Ctrl+V.
        // To learn more about selection, visit https://aka.ms/terminal-selection
        { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
        { "command": "paste", "keys": "ctrl+v" },

        // Press Ctrl+Shift+F to open the search box
        { "command": "find", "keys": "ctrl+shift+f" },

        // Adjust font size
        { "command": { "action": "adjustFontSize", "delta": -1 }, "keys": "ctrl+-" },
        { "command": { "action": "adjustFontSize", "delta": 1 }, "keys": "ctrl+=" },

        // Create new tabs
        { "command": { "action": "newTab", "index": 0 }, "keys": "ctrl+shift+0" },
        { "command": { "action": "newTab", "index": 1 }, "keys": "ctrl+shift+1" },
        { "command": { "action": "newTab", "index": 2 }, "keys": "ctrl+shift+2" },
        { "command": { "action": "newTab", "index": 3 }, "keys": "ctrl+shift+3" },
        { "command": { "action": "newTab", "index": 4 }, "keys": "ctrl+shift+4" },
        { "command": { "action": "newTab", "index": 5 }, "keys": "ctrl+shift+5" },
        { "command": { "action": "newTab", "index": 6 }, "keys": "ctrl+shift+6" },
        { "command": { "action": "newTab", "index": 7 }, "keys": "ctrl+shift+7" },
        { "command": { "action": "newTab", "index": 8 }, "keys": "ctrl+shift+8" },
        { "command": { "action": "newTab", "index": 9 }, "keys": "ctrl+shift+9" },

        // Switching between tabs
        { "command": { "action": "switchToTab", "index": 0 }, "keys": "ctrl+alt+0" },
        { "command": { "action": "switchToTab", "index": 1 }, "keys": "ctrl+alt+1" },
        { "command": { "action": "switchToTab", "index": 2 }, "keys": "ctrl+alt+2" },
        { "command": { "action": "switchToTab", "index": 3 }, "keys": "ctrl+alt+3" },
        { "command": { "action": "switchToTab", "index": 4 }, "keys": "ctrl+alt+4" },
        { "command": { "action": "switchToTab", "index": 5 }, "keys": "ctrl+alt+5" },
        { "command": { "action": "switchToTab", "index": 6 }, "keys": "ctrl+alt+6" },
        { "command": { "action": "switchToTab", "index": 7 }, "keys": "ctrl+alt+7" },
        { "command": { "action": "switchToTab", "index": 8 }, "keys": "ctrl+alt+8" },
        { "command": { "action": "switchToTab", "index": 9 }, "keys": "ctrl+alt+9" },

        // Press Alt+Shift+D to open a new pane.
        // - "split": "auto" makes this pane open in the direction that provides the most surface area.
        // - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
        // To learn more about panes, visit https://aka.ms/terminal-panes
        { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" },
        { "command": { "action": "splitPane", "split": "horizontal"}, "keys": "alt+shift+-" },
        { "command": { "action": "splitPane", "split": "vertical"}, "keys": "alt+shift+plus" },

        { "command": { "action": "moveFocus", "direction": "down" }, "keys": "alt+down" },
        { "command": { "action": "moveFocus", "direction": "up" }, "keys": "alt+up" },
        { "command": { "action": "moveFocus", "direction": "left" }, "keys": "alt+left" },
        { "command": { "action": "moveFocus", "direction": "right" }, "keys": "alt+right" }
    ]
}

I’ll make sure our documentation’s clearer about sources and how to deal with dynamic profiles while we don’t have a setting UI. Thanks a bunch :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NickITGuy picture NickITGuy  Â·  3Comments

miniksa picture miniksa  Â·  3Comments

dev-logan picture dev-logan  Â·  3Comments

xmm1989218 picture xmm1989218  Â·  3Comments

TayYuanGeng picture TayYuanGeng  Â·  3Comments