What is the profile for when the "Default Terminal" kicks in? #15984

Closed
opened 2026-01-31 04:54:01 +00:00 by claunia · 10 comments
Owner

Originally created by @CrendKing on GitHub (Nov 28, 2021).

Description of the new feature/enhancement

When I set Windows Terminal as the Default Terminal app, every time I launch a .bat or .cmd, or a cmd.exe shortcut, Windows Terminal would launch instead. What is the profile for that tab/session? Is there some hidden "conhost" profile that I don't find in settings.json, or is it simply applying the "defaults" section?

I ask this because as https://github.com/microsoft/terminal/issues/2241 says, sometimes the title is long. I can put "suppressApplicationTitle": true in defaults to solve this, but it also affects all other explicit profiles. I'd also want to use different color scheme to indicate a tab is launched using the "Default Terminal" feature.

If this "conhost" profile is not existed or planned, do you think it's an idea to consider?

Originally created by @CrendKing on GitHub (Nov 28, 2021). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement When I set Windows Terminal as the Default Terminal app, every time I launch a .bat or .cmd, or a cmd.exe shortcut, Windows Terminal would launch instead. What is the profile for that tab/session? Is there some hidden "conhost" profile that I don't find in settings.json, or is it simply applying the "defaults" section? I ask this because as https://github.com/microsoft/terminal/issues/2241 says, sometimes the title is long. I can put `"suppressApplicationTitle": true` in `defaults` to solve this, but it also affects all other explicit profiles. I'd also want to use different color scheme to indicate a tab is launched using the "Default Terminal" feature. If this "conhost" profile is not existed or planned, do you think it's an idea to consider? <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> <!-- A clear and concise description of what you want to happen. -->
Author
Owner

@zadjii-msft commented on GitHub (Nov 29, 2021):

Right now (as of 1.11 I think), we're just using the profiles.defaults block for tabs created to host commandline invocations. I believe in 1.12 there's a bit of heuristic "matching" on commandlines, to try and find the profile with the same commandline, and use those settings instead. Which version are you on? Do you have some example commandlines (& profiles) we could test to make sure it's working?

@zadjii-msft commented on GitHub (Nov 29, 2021): Right now (as of 1.11 I think), we're just using the `profiles.defaults` block for tabs created to host commandline invocations. I believe in 1.12 there's a bit of heuristic "matching" on commandlines, to try and find the profile with the same commandline, and use those settings instead. Which version are you on? Do you have some example commandlines (& profiles) we could test to make sure it's working?
Author
Owner

@CrendKing commented on GitHub (Nov 29, 2021):

I'm currently at 1.11.2921.0. I'm on Windows 11. If I left everything as default, when I run the "Command Prompt" item in "Windows Tools", the tab title is something like "Administrator: C:\Users\CrendKing\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools\Command Prompt.lnk". It pretty much takes the long tab bar to display that. If I put "suppressApplicationTitle": true in defaults, it becomes "Default", but now all my other profiles such as PowerShell are also affected. I know I could re-introduce "suppressApplicationTitle": false to individual profiles, but that's sub-optimal.

If it is matching command line in 1.12, what does it means for running .bat and .cmd files? Is there "catch-all" solution?

@CrendKing commented on GitHub (Nov 29, 2021): I'm currently at 1.11.2921.0. I'm on Windows 11. If I left everything as default, when I run the "Command Prompt" item in "Windows Tools", the tab title is something like "Administrator: C:\Users\CrendKing\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools\Command Prompt.lnk". It pretty much takes the long tab bar to display that. If I put `"suppressApplicationTitle": true` in `defaults`, it becomes "Default", but now all my other profiles such as PowerShell are also affected. I know I could re-introduce `"suppressApplicationTitle": false` to individual profiles, but that's sub-optimal. If it is matching command line in 1.12, what does it means for running .bat and .cmd files? Is there "catch-all" solution?
Author
Owner

@zadjii-msft commented on GitHub (Feb 3, 2022):

Sorry, dunno how this fell off the triage queue...

The Windows Tools shortcut to Command Prompt should use the Command Prompt profile, the one with the guid {0caa0dad-35be-5f56-a8ff-afceeeaa6101}.

tabWidthMode might be a more ergonomic solution. Alternatively, you might be able to just set tabTitle for just the command prompt profile. INTEREESTING, that gets blown away when launching from that lnk.

what does it means for running .bat and .cmd files? Is there "catch-all" solution?

That's a good question. I'll tap in @lhecker who wrote the matching. I believe you can just make a profile for the bat file in question, and we'll use those settings. However, that is kinda annoying if you have a ton of different bat files.

@zadjii-msft commented on GitHub (Feb 3, 2022): Sorry, dunno how this fell off the triage queue... The Windows Tools shortcut to Command Prompt _should_ use the Command Prompt profile, the one with the guid `{0caa0dad-35be-5f56-a8ff-afceeeaa6101}`. [`tabWidthMode`](https://docs.microsoft.com/en-us/windows/terminal/customize-settings/appearance#tab-width-mode) might be a more ergonomic solution. ~Alternatively, you might be able to just set `tabTitle` for just the command prompt profile.~ INTEREESTING, that gets blown away when launching from that `lnk`. > what does it means for running .bat and .cmd files? Is there "catch-all" solution? That's a good question. I'll tap in @lhecker who wrote the matching. I believe you can just make a profile for the `bat` file in question, and we'll use those settings. However, that is kinda annoying if you have a ton of different bat files.
Author
Owner

@CrendKing commented on GitHub (Feb 3, 2022):

Thank you. I'm pretty sure it does not use {0caa0dad-35be-5f56-a8ff-afceeeaa6101}, because if I put "suppressApplicationTitle": true to that profile, I still get long title from the shortcut. Only if I put "suppressApplicationTitle": true to the defaults can I affect the title.

My tabWidthMode is set to "titleLength" because some titles are long but informative. Setting it to the default "equal" would truncate and lose information.

@CrendKing commented on GitHub (Feb 3, 2022): Thank you. I'm pretty sure it does not use `{0caa0dad-35be-5f56-a8ff-afceeeaa6101}`, because if I put `"suppressApplicationTitle": true` to that profile, I still get long title from the shortcut. Only if I put `"suppressApplicationTitle": true` to the `defaults` can I affect the title. My `tabWidthMode` is set to "titleLength" because some titles are long but informative. Setting it to the default "equal" would truncate and lose information.
Author
Owner

@lhecker commented on GitHub (Feb 3, 2022):

@CrendKing Try adding "background": "#f00" to your {0caa0dad-35be-5f56-a8ff-afceeeaa6101} profile. When I do that and launch a .bat file, it'll properly open a tab with red background, indicating that the cmd.exe profile was picked.

To answer the question how a profile is chosen when running a .bat file:
When you launch a .bat from your Desktop or from Explorer, it'll actually execute:

C:\WINDOWS\system32\cmd.exe /c ""<absolute path to .bat file>" "

This is because .bat files aren't executables and only executables can be the first argument on a command line.
What Windows Terminal does is to pick the profile with "the longest common case-insensitive prefix" of your command line.

For instance if you have two profiles with the command lines cmd.exe and cmd.exe /c this happens if you launch an application with the following command line:

  • cmd.exe /c foo.bat -->the cmd.exe /c profile is picked
  • cmd.exe /k /c foo.bat -->the cmd.exe profile is picked
  • cmd.exe -->the cmd.exe profile is picked

In this case the command line for the standard {0caa0dad-35be-5f56-a8ff-afceeeaa6101} profile is "%SystemRoot%\\System32\\cmd.exe", which resolves to C:\Windows\System32\cmd.exe, which is a common prefix of your C:\WINDOWS\system32\cmd.exe /c ""<absolute path to .bat file>" " command line.


@zadjii-msft I fear this might be a bug specifically in our suppressApplicationTitle implementation during hand-off. I believe we should mark this issue as a bug.

@lhecker commented on GitHub (Feb 3, 2022): @CrendKing Try adding `"background": "#f00"` to your `{0caa0dad-35be-5f56-a8ff-afceeeaa6101}` profile. When I do that and launch a .bat file, it'll properly open a tab with red background, indicating that the cmd.exe profile was picked. To answer the question how a profile is chosen when running a .bat file: When you launch a .bat from your Desktop or from Explorer, it'll actually execute: ``` C:\WINDOWS\system32\cmd.exe /c ""<absolute path to .bat file>" " ``` This is because .bat files aren't executables and only executables can be the first argument on a command line. What Windows Terminal does is to pick the profile with "the longest common case-insensitive prefix" of your command line. For instance if you have two profiles with the command lines `cmd.exe` and `cmd.exe /c` this happens if you launch an application with the following command line: * `cmd.exe /c foo.bat` -->the `cmd.exe /c` profile is picked * `cmd.exe /k /c foo.bat` -->the `cmd.exe` profile is picked * `cmd.exe` -->the `cmd.exe` profile is picked In this case the command line for the standard `{0caa0dad-35be-5f56-a8ff-afceeeaa6101}` profile is `"%SystemRoot%\\System32\\cmd.exe"`, which resolves to `C:\Windows\System32\cmd.exe`, which is a common prefix of your `C:\WINDOWS\system32\cmd.exe /c ""<absolute path to .bat file>" "` command line. --- @zadjii-msft I fear this might be a bug specifically in our `suppressApplicationTitle` implementation during hand-off. I believe we should mark this issue as a bug.
Author
Owner

@CrendKing commented on GitHub (Feb 3, 2022):

Try adding "background": "#f00" to your {0caa0dad-35be-5f56-a8ff-afceeeaa6101} profile. When I do that and launch a .bat file, it'll properly open a tab with red background, indicating that the cmd.exe profile was picked.

That's weird. I can't reproduce what you say here.

Here is what I did:

  1. Make WT the default terminal app.
  2. Revert the settings.json to default, and add the background color. I attach the full settings.json below.
  3. Write a .bat file with content ping 127.0.0.1. Double click and see it executes in WT.
  4. The background color is still black.

On the other hand, if I manually create a new WT tab with the "Command Prompt" profile (Ctrl+Shift+2), I do see the red background. Something seems to be wrong with the default terminal feature.

settings.json
// This file was initially generated by Windows Terminal 1.11.3471.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": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",

    // 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": false,

    // 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.
        },
        "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": "Command Prompt",
                "commandline": "cmd.exe",
                "hidden": false,
                "background": "#f00"
            }
        ]
    },

    // Add custom color schemes to this array.
    // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
    "schemes": [],

    // Add custom actions and keybindings to this array.
    // To unbind a key combination from your defaults.json, set the command to "unbound".
    // To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
    "actions":
    [
        // 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" },

        // 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" }
    ]
}
@CrendKing commented on GitHub (Feb 3, 2022): > Try adding `"background": "#f00"` to your `{0caa0dad-35be-5f56-a8ff-afceeeaa6101}` profile. When I do that and launch a .bat file, it'll properly open a tab with red background, indicating that the cmd.exe profile was picked. That's weird. I can't reproduce what you say here. Here is what I did: 1. Make WT the default terminal app. 2. Revert the settings.json to default, and add the background color. I attach the full settings.json below. 3. Write a .bat file with content `ping 127.0.0.1`. Double click and see it executes in WT. 4. The background color is still black. On the other hand, if I manually create a new WT tab with the "Command Prompt" profile (Ctrl+Shift+2), I do see the red background. Something seems to be wrong with the default terminal feature. <details> <summary>settings.json</summary> ```json // This file was initially generated by Windows Terminal 1.11.3471.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": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", // 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": false, // 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. }, "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": "Command Prompt", "commandline": "cmd.exe", "hidden": false, "background": "#f00" } ] }, // Add custom color schemes to this array. // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes "schemes": [], // Add custom actions and keybindings to this array. // To unbind a key combination from your defaults.json, set the command to "unbound". // To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings "actions": [ // 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" }, // 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" } ] } ``` </details>
Author
Owner

@lhecker commented on GitHub (Feb 3, 2022):

This is what I see - Windows Terminal 1.12.10334.0:
image

Is this maybe a Windows 10 thing? I only have Windows 11 installed right now. 🤔
Nevermind you said you're on 11 yourself.

@lhecker commented on GitHub (Feb 3, 2022): This is what I see - Windows Terminal 1.12.10334.0: ![image](https://user-images.githubusercontent.com/2256941/152381804-69d78099-4af4-422e-a799-d9b9d3ed24cd.png) ~Is this maybe a Windows 10 thing? I only have Windows 11 installed right now. 🤔~ Nevermind you said you're on 11 yourself.
Author
Owner

@CrendKing commented on GitHub (Feb 3, 2022):

My WT is still 1.11.3471.0. Just installed the preview 1.12 and I'm observing your result now! And if I just add "suppressApplicationTitle": true to that cmd profile, it's now effective.

Guess it's already fixed. I'll just wait for the release. Feel free to close the issue.

@CrendKing commented on GitHub (Feb 3, 2022): My WT is still 1.11.3471.0. Just installed the preview 1.12 and I'm observing your result now! And if I just add `"suppressApplicationTitle": true` to that cmd profile, it's now effective. Guess it's already fixed. I'll just wait for the release. Feel free to close the issue.
Author
Owner

@lhecker commented on GitHub (Feb 3, 2022):

Huh interesting... That's somewhat unexpected for me. I'll look into what changed between 1.11 and 1.12 later today if I can.
I'm glad it's fixed! 🙂

@lhecker commented on GitHub (Feb 3, 2022): Huh interesting... That's somewhat unexpected for me. I'll look into what changed between 1.11 and 1.12 later today if I can. I'm glad it's fixed! 🙂
Author
Owner

@lhecker commented on GitHub (Feb 3, 2022):

Duh. I already found it. 😅
The profile matching I mentioned before was only merged into v1.12.2922.0 (PR: https://github.com/microsoft/terminal/pull/11390)
Before that (1.11 and earlier), launching executables from outside of Windows Terminal always used the default profile, which is exactly the behavior you're seeing.

The good news is that 1.12 will be released as the stable, non-Preview version very soon. 🙂

@lhecker commented on GitHub (Feb 3, 2022): Duh. I already found it. 😅 The profile matching I mentioned before was only merged into [v1.12.2922.0](https://github.com/microsoft/terminal/releases/tag/v1.12.2922.0) (PR: https://github.com/microsoft/terminal/pull/11390) Before that (1.11 and earlier), launching executables from outside of Windows Terminal always used the default profile, which is exactly the behavior you're seeing. The good news is that 1.12 will be released as the stable, non-Preview version very soon. 🙂
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15984