startingDirectory and splitMode ignored in settings file #18152

Closed
opened 2026-01-31 06:05:11 +00:00 by claunia · 18 comments
Owner

Originally created by @awa5114 on GitHub (Aug 11, 2022).

Windows Terminal version

1.14.1962.0

Windows build number

10.0.19042.0

Other Software

No response

Steps to reproduce

{
    "$help": "https://aka.ms/terminal-documentation",
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "actions": 
    [
        {
            "command": 
            {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        {
            "command": "paste",
            "keys": "ctrl+v"
        },
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        {
            "command": 
            {
                "action": "splitPane",
                "split": "down",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+minus"
        }
    ],
    "copyFormatting": "none",
    "copyOnSelect": false,
    "defaultProfile": "{dd06fdc4-e3c7-404a-ba9c-ead0245d608b}",
    "profiles": 
    {
        "defaults": {
			
		},
        "list": 
        [
            {
                "commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": false,
                "name": "Windows PowerShell"
            },
            {
                "commandline": "%SystemRoot%\\System32\\cmd.exe",
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": false,
                "name": "Command Prompt"
            },
            {
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell",
                "source": "Windows.Terminal.PowershellCore"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "commandline": "pwsh.exe -ExecutionPolicy ByPass -NoExit -Command \"& C:\\Users\\amine.aboufirass\\miniconda3\\shell\\condabin\\conda-hook.ps1 ; conda activate C:\\Users\\amine.aboufirass\\miniconda3\"",
                "guid": "{db6044f2-9daa-458b-afd6-20cbd1db506d}",
                "hidden": false,
                "name": "Anaconda Powershell Prompt"
            },
            {
                "commandline": "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" -noe -c \"&{Import-Module \"\"\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\Common7\\Tools\\Microsoft.VisualStudio.DevShell.dll\"\"\"; Enter-VsDevShell f47eb35f}\"",
                "guid": "{dd06fdc4-e3c7-404a-ba9c-ead0245d608b}",
                "hidden": false,
                "name": "Developer Command Prompt VS2019",
				"startDirectory": "D:/Dev"
            }
        ]
    },
    "schemes":  [...]
}
  • The opened default prompt (Developer Command Prompt VS2019) Does not open in the directory listed under startDirectory
  • When attempting to split a pane horizontally using shift+alt+- the new pane does not replicate the same directory, unless it is the home directory

Expected Behavior

I expect splitMode="duplicate to start any new panes in the directory of the parent pane.
I expect startingDirectory="D:/Dev" to open the profile in D:/Dev

Actual Behavior

splitMode="duplicate to starts any new panes in home directory regardless of which directory the parent pane is in
startingDirectory="D:/Dev" does not affect the default directory when opening the terminal

Originally created by @awa5114 on GitHub (Aug 11, 2022). ### Windows Terminal version 1.14.1962.0 ### Windows build number 10.0.19042.0 ### Other Software _No response_ ### Steps to reproduce ``` { "$help": "https://aka.ms/terminal-documentation", "$schema": "https://aka.ms/terminal-profiles-schema", "actions": [ { "command": { "action": "copy", "singleLine": false }, "keys": "ctrl+c" }, { "command": "paste", "keys": "ctrl+v" }, { "command": "find", "keys": "ctrl+shift+f" }, { "command": { "action": "splitPane", "split": "down", "splitMode": "duplicate" }, "keys": "alt+shift+minus" } ], "copyFormatting": "none", "copyOnSelect": false, "defaultProfile": "{dd06fdc4-e3c7-404a-ba9c-ead0245d608b}", "profiles": { "defaults": { }, "list": [ { "commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "hidden": false, "name": "Windows PowerShell" }, { "commandline": "%SystemRoot%\\System32\\cmd.exe", "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "hidden": false, "name": "Command Prompt" }, { "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", "hidden": false, "name": "PowerShell", "source": "Windows.Terminal.PowershellCore" }, { "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}", "hidden": false, "name": "Azure Cloud Shell", "source": "Windows.Terminal.Azure" }, { "commandline": "pwsh.exe -ExecutionPolicy ByPass -NoExit -Command \"& C:\\Users\\amine.aboufirass\\miniconda3\\shell\\condabin\\conda-hook.ps1 ; conda activate C:\\Users\\amine.aboufirass\\miniconda3\"", "guid": "{db6044f2-9daa-458b-afd6-20cbd1db506d}", "hidden": false, "name": "Anaconda Powershell Prompt" }, { "commandline": "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" -noe -c \"&{Import-Module \"\"\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\Common7\\Tools\\Microsoft.VisualStudio.DevShell.dll\"\"\"; Enter-VsDevShell f47eb35f}\"", "guid": "{dd06fdc4-e3c7-404a-ba9c-ead0245d608b}", "hidden": false, "name": "Developer Command Prompt VS2019", "startDirectory": "D:/Dev" } ] }, "schemes": [...] } ``` - The opened default prompt (Developer Command Prompt VS2019) Does not open in the directory listed under `startDirectory` - When attempting to split a pane horizontally using shift+alt+- the new pane does not replicate the same directory, unless it is the home directory ### Expected Behavior I expect `splitMode="duplicate` to start any new panes in the directory of the parent pane. I expect `startingDirectory="D:/Dev"` to open the profile in `D:/Dev` ### Actual Behavior `splitMode="duplicate` to starts any new panes in home directory regardless of which directory the parent pane is in `startingDirectory="D:/Dev"` does not affect the default directory when opening the terminal
claunia added the Needs-TriageIssue-BugIn-PRNeeds-Tag-FixNeeds-Attention labels 2026-01-31 06:05:12 +00:00
Author
Owner

@237dmitry commented on GitHub (Aug 11, 2022):

startingDirectory or startDirectory in YOUR settings.json?

@237dmitry commented on GitHub (Aug 11, 2022): `startingDirectory` or `startDirectory` in YOUR settings.json?
Author
Owner

@awa5114 commented on GitHub (Aug 11, 2022):

@237dmitry I tried both. Neither worked.

@awa5114 commented on GitHub (Aug 11, 2022): @237dmitry I tried both. Neither worked.
Author
Owner

@zadjii-msft commented on GitHub (Aug 11, 2022):

Firstly, yea it's startingDirectory.

Second, did you configure your shell to actually tell the Terminal about it's CWD/?

@zadjii-msft commented on GitHub (Aug 11, 2022): Firstly, yea it's [`startingDirectory`](https://docs.microsoft.com/en-us/windows/terminal/customize-settings/profile-general#starting-directory). Second, did you [configure your shell](https://docs.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory) to actually tell the Terminal about it's CWD/?
Author
Owner

@awa5114 commented on GitHub (Aug 11, 2022):

@zadjii-msft I added the following to my Powershell profile based on the link you provided:

function prompt {
  $loc = $($executionContext.SessionState.Path.CurrentLocation);
  $out = "PS $loc$('>' * ($nestedPromptLevel + 1)) ";
  $out += "$([char]27)]9;9;`"$loc`"$([char]27)\"
  return $out
}

Then I double checked that my settings included startingDirectory, which they were.

The behavior unfortunately persists. I still have the same problem.

@awa5114 commented on GitHub (Aug 11, 2022): @zadjii-msft I added the following to my Powershell profile based on the link you provided: ``` function prompt { $loc = $($executionContext.SessionState.Path.CurrentLocation); $out = "PS $loc$('>' * ($nestedPromptLevel + 1)) "; $out += "$([char]27)]9;9;`"$loc`"$([char]27)\" return $out } ``` Then I double checked that my settings included `startingDirectory`, which they were. The behavior unfortunately persists. I still have the same problem.
Author
Owner

@zadjii-msft commented on GitHub (Aug 11, 2022):

Hmm. Maybe the cwd sequence is getting lost.

Can you try opening this profile with the debug tap to get a trace of all the input and output/? Once it's open, cd once, just to make sure that CWD changes propagate out. Send us a screenshot and we might be able to figure out what the Terminal thinks it's getting here.


Alternatively, maybe it's the `"alt+shift+minus"` that's tripping up the keybindings. Those ones are sometimes a little wonky, esp on other keyboard layouts. As a sanity check, try binding that to something like, `f1` instead.
@zadjii-msft commented on GitHub (Aug 11, 2022): Hmm. Maybe the cwd sequence is getting lost. Can you try opening this profile with the [debug tap](https://github.com/microsoft/terminal/wiki/Enabling-the-debug-tap) to get a trace of all the input and output/? Once it's open, `cd` once, just to make sure that CWD changes propagate out. Send us a screenshot and we might be able to figure out what the Terminal thinks it's getting here. <hr> Alternatively, maybe it's the `"alt+shift+minus"` that's tripping up the keybindings. Those ones are sometimes a little wonky, esp on other keyboard layouts. As a sanity check, try binding that to something like, `f1` instead.
Author
Owner

@awa5114 commented on GitHub (Aug 12, 2022):

Here's the output from the debug tap:

image

Using "f1" instead of "alt+shift+minus" in the keybinding does not make a difference.

@awa5114 commented on GitHub (Aug 12, 2022): Here's the output from the debug tap: ![image](https://user-images.githubusercontent.com/24267968/184304413-71289833-7393-400c-afd9-6b50b2b087b7.png) Using "f1" instead of "alt+shift+minus" in the keybinding does not make a difference.
Author
Owner

@awa5114 commented on GitHub (Aug 12, 2022):

I changed the relevant part in settings.json to

{
            "command": 
            {
                "action": "splitPane",
                "split": "horizontal",
                "splitMode": "duplicate"
            },
            "keys": "shift+alt+-"
        }
}

And now it seems to duplicate the profile and CWD in all profiles except for the Visual Studio Developer command prompt. That seems to indicate that Windows Terminal works fine, and there's something about the way I've set up the Visual Studio profile which causes it to behave this way. Closing.

@awa5114 commented on GitHub (Aug 12, 2022): I changed the relevant part in `settings.json` to ``` { "command": { "action": "splitPane", "split": "horizontal", "splitMode": "duplicate" }, "keys": "shift+alt+-" } } ``` And now it seems to duplicate the profile and CWD in all profiles except for the Visual Studio Developer command prompt. That seems to indicate that Windows Terminal works fine, and there's something about the way I've set up the Visual Studio profile which causes it to behave this way. Closing.
Author
Owner

@zadjii-msft commented on GitHub (Aug 12, 2022):

Huh. Interesting! I know there have been issues with that in the past with ubuntu.exe as well. Maybe Enter-VsDevShell always switches the CWD to %USERPROFILE%\source\repos, regardless of the starting directory.

Glad you (sorta) figured it out!

@zadjii-msft commented on GitHub (Aug 12, 2022): Huh. Interesting! I know there have been issues with that in the past with `ubuntu.exe` as well. Maybe `Enter-VsDevShell` always switches the CWD to `%USERPROFILE%\source\repos`, regardless of the starting directory. Glad you (sorta) figured it out!
Author
Owner

@awa5114 commented on GitHub (Aug 14, 2022):

Sorry, I have to reopen this. I tried using the same settings file on another machine and got the same unwanted behavior. So I'm leaning more towards the idea that this is definitely Windows Terminal related.

@awa5114 commented on GitHub (Aug 14, 2022): Sorry, I have to reopen this. I tried using the same settings file on another machine and got the same unwanted behavior. So I'm leaning more towards the idea that this is definitely Windows Terminal related.
Author
Owner

@zadjii-msft commented on GitHub (Aug 15, 2022):

got the same unwanted behavior

Like, got the same behavior with cmd/powershell? I thought we had debugged this down to an issue with Enter-VsDevShell/?

@zadjii-msft commented on GitHub (Aug 15, 2022): > got the same unwanted behavior Like, got the same behavior with cmd/powershell? I thought we had debugged this down to an issue with `Enter-VsDevShell`/?
Author
Owner

@awa5114 commented on GitHub (Aug 17, 2022):

@zadjii-msft We hadn't debugged anything, really. I submitted the debug tap like you asked and then closed the issue before you had a chance to respond when I (incorrectly) concluded my issue was resolved.

I'm not sure what Enter-VsDevShell is, but I don't think we had gotten far enough to determine the root cause of this issue. I would kindly refer you back to the debug tap I submitted a couple of days ago.

@awa5114 commented on GitHub (Aug 17, 2022): @zadjii-msft We hadn't debugged anything, really. I submitted the debug tap like you asked and then closed the issue before you had a chance to respond when I (incorrectly) concluded my issue was resolved. I'm not sure what `Enter-VsDevShell` is, but I don't think we had gotten far enough to determine the root cause of this issue. I would kindly refer you back to the debug tap I submitted a couple of days ago.
Author
Owner

@DHowett commented on GitHub (Mar 1, 2023):

I'm sorry for the radio silence here! Thanks for your patience.

Based on the symptoms and your configuration here, it seems like there are two issues:

  1. If you have not configured cmd/powershell to "tell" terminal about their starting directory, duplicate doesn't work properly. This is an unfortunate but documented consequence of how processes on Windows work.
  2. the VS dev shells are impacted explicitly, even if you follow the above docs

For 1, the docs reign supreme. For 2, however... every VS dev shell profile is configured to use a Visual Studio command Enter-VsDevShell. That command(let) explicitly overrides any starting directory, which is somewhat frustrating. You can fix this by adding -SkipAutomaticLocation to the commandline for any VS Dev Shell profile. We should document or fix this.

image

Does that help at all?

@DHowett commented on GitHub (Mar 1, 2023): I'm sorry for the radio silence here! Thanks for your patience. Based on the symptoms and your configuration here, it seems like there are two issues: 1. If you have not configured cmd/powershell to "tell" terminal about their starting directory, duplicate doesn't work properly. This is an unfortunate but [documented](https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory) consequence of how processes on Windows work. 1. _the VS dev shells_ are impacted explicitly, even if you follow the above docs For 1, the docs reign supreme. For 2, however... every VS dev shell profile is configured to use a Visual Studio command `Enter-VsDevShell`. That command(let) explicitly overrides any starting directory, which is somewhat frustrating. You can fix this by adding `-SkipAutomaticLocation` to the commandline for any VS Dev Shell profile. We should document or fix this. <img width="304" alt="image" src="https://user-images.githubusercontent.com/189190/222282117-a556638d-d5ae-471f-90a7-53d9b07ee2bc.png"> Does that help at all?
Author
Owner

@awa5114 commented on GitHub (Mar 7, 2023):

@DHowett I see, so this appears to be specific for profiles that use VsDevShell. Yes, in my case adding -SkipAutomaticLocation does help. When I split the pane it now keeps the same base folder as the one specified in my original pane. Thanks.

@awa5114 commented on GitHub (Mar 7, 2023): @DHowett I see, so this appears to be specific for profiles that use `VsDevShell`. Yes, in my case adding `-SkipAutomaticLocation` does help. When I split the pane it now keeps the same base folder as the one specified in my original pane. Thanks.
Author
Owner

@DHowett commented on GitHub (Mar 7, 2023):

Thanks for confirming!

Personally, I'd love to add that for everyone . . . @heaths, how integral to the continuity of "dev shell" is that it ignore the user's starting directory? I know that the start menu shortcuts work one way, but perhaps we can change that contract a bit?

@DHowett commented on GitHub (Mar 7, 2023): Thanks for confirming! Personally, I'd love to add that for everyone . . . @heaths, how integral to the continuity of "dev shell" is that it ignore the user's starting directory? I know that the start menu shortcuts work one way, but perhaps we can change that contract a bit?
Author
Owner

@heaths commented on GitHub (Mar 7, 2023):

I doubt it's needed. I imagine it was probably maintained for legacy reasons, but since env vars like PATH are updated I see little reason to maintain it i.e., just blindly add -SkipAutomaticLocation to each profile going forward. Let me track down an owner for the scripts and see if they'll comment otherwise.

@heaths commented on GitHub (Mar 7, 2023): I doubt it's needed. I imagine it was probably maintained for legacy reasons, but since env vars like `PATH` are updated I see little reason to maintain it i.e., just blindly add `-SkipAutomaticLocation` to each profile going forward. Let me track down an owner for the scripts and see if they'll comment otherwise.
Author
Owner

@carlos-zamora commented on GitHub (Mar 22, 2023):

@heaths did you have any luck?

@carlos-zamora commented on GitHub (Mar 22, 2023): @heaths did you have any luck?
Author
Owner

@heaths commented on GitHub (Mar 22, 2023):

@trippwill indicated in email with @DHowett and I that it should be safe to add. It's been available since the PowerShell dev prompt was added, which I seem to recall this code assumes already.

@heaths commented on GitHub (Mar 22, 2023): @trippwill indicated in email with @DHowett and I that it should be safe to add. It's been available since the PowerShell dev prompt was added, which I seem to recall this code assumes already.
Author
Owner

@DHowett commented on GitHub (Mar 23, 2023):

Oh, I just realized that you're not even using the automatically generated VS profiles! Hah!

It also turns out that our automatically-generated VS PowerShell profiles already use -SkipAutomaticLocation.

I'm gonna close this out, but I have made sure that the CMD version of these profiles does the same thing in #15035.

@DHowett commented on GitHub (Mar 23, 2023): Oh, I just realized that you're not even using the automatically generated VS profiles! Hah! It also turns out that our automatically-generated VS PowerShell profiles _already_ use `-SkipAutomaticLocation`. I'm gonna close this out, but I have made sure that the _CMD_ version of these profiles does the same thing in #15035.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18152