terminal: Starting directory no longer respected
Commit where this occurs: e0f131121b08dc5d6485e4bd985ac2c7e32b6339
Commit where this didn’t occur yet: d5b8e7c32f7a419a7d467eab038251ee529056e6
Since the startingDirectory
profiles.json setting was introduced (which is set to %USERPROFILE%
by default), the current starting directory is no longer respected and the terminal always starts in %USERPROFILE%
.
The startingDirectory
setting is great to make sure the terminal doesn’t always start in c:\windows\system32
. It might however be better that its not used when starting Windows Terminal from a folder.
With starting WT from a folder
I mean launching wt.exe
(or wtd.exe
) from an open cmd, or in Windows Explorer via its address bar.
The folder of the parent cmd process (or Explorer process) should then be used by default and startingDirectory
should be used as a fallback. For example, when launching Windows Terminal from the start menu.
Steps to reproduce
- Make sure
startingDirectory
is set to%USERPROFILE%
:
{
...
"profiles": [{
"startingDirectory": "%USERPROFILE%",
}, {
...
}
],
...
}
- Open an explorer window in a random folder (for example the root of the C drive)
- Type
wt
(orwtd
) in the address bard
Expected behavior
Windows Terminal should open with the terminals path set to the folder opened in explorer. In the example this would be the root of the C drive: C:\
.
Actual behavior
Windows Terminal opens with the terminals path set to the user profile path.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 39
- Comments: 57 (18 by maintainers)
Commits related to this issue
- This is a prototype for #878 — committed to microsoft/terminal by zadjii-msft 5 years ago
- Add support for commandline args to `wt.exe` (#4023) ## Summary of the Pull Request Adds support for commandline arguments to the Windows Terminal, in accordance with the spec in #3495 ## Refer... — committed to microsoft/terminal by zadjii-msft 4 years ago
@DHowett-MSFT is correct.
"startingDirectory": "~"
doesn’t work for WSL shells, but this does:Hey all,
So this turned out to be a more complicated story that it seemed on the surface. There’s more information in #3547 on all the edge cases with this scenario, feel free to read that thread if you’re interested in more details.
Going forward, the official way to make this scenario work will be typing
wt -d .
into the explorer bar. That will tellwt
to open in the current working directory. I know this isn’t ideal, but frankly it’s the only solution that still supports all the user stories we want. This functionality was added in #4023, and should be arriving in v0.9.Thanks everyone!
I’m totally agree with @nphmuller from this comment. In my workflow there is no time to remember about -p parameter. For me behavior same like cmd, powershell, sh … is killer feature of Windows explorer. It would be nice when
wt
will be compatible with shuch a behavior.I don’t see it explicitly mentioned in this thread, but adding/setting
"startingDirectory": "",
for any particular profile in the settings.json will cause the behavior specified in https://github.com/microsoft/terminal/pull/3547 i.e. typewt
in the explorer bar and start the default terminal profile in the current explorer directory.hopefully this makes it clearer for people arriving here by Google or whatever.
Just saw this issue, the following works fine for me for getting into the home directory for WSL:
"commandline": "wsl.exe ~ -d Ubuntu",
no
startingDirectory
entry for wslTry
"startingDirectory": "."
for workaround.see HERE for example.
@fghzxm For my personally they both are about just as important. So that doesn’t help. 😁
My main point is: Bash (WSL), cmd, PowerShell, Windows Explorer and VSCode (Explorer and VSCode via the
.
parameter) implemented a pattern where I could simply type the name of the executable, and it would open in the current directory. When starting via the start menu (or Run) it starts in the home directory, (or in a default view in the case on Explorer and VSCode).I think it’d be nice if WT could also implement this widely used pattern. Using a
-p
parameter would work, but it would make this a bit harder the guess, and harder to use because it requires WT specific know-how.Sorry for not coming up with a better solution. Just wanted to reiterate the point.
//wsl$/Ubuntu-18.04/home/username
for me, since I’m usingUbuntu 18.04 LTS
from Microsoft Store.@ffes You will get
/mnt/c/Windows/System32
if you invoke the plainwsl
command. You wantwsl ~
.Just found this in the docs, seems like you can use forward slashes and not be bothered by escaping:
//wsl$/Ubuntu/home/username
.As of v0.5, you’ll need
"startingDirectory": null
for that workaround. This was regressed unintentionally, but it wasn’t ever really a supported workaround, and we’re still hoping for a real fix, but this will work for now.A really simple work around is add
cd
to the end of bashrc.echo "cd" >> ~/.bashrc
I have a different, but connected issue. Is it somehow possible to keep the current working directory when I open a tab or split from within Windows Terminal itself?
What I mean is:
D:\
D:\
Same thing for splits.
You’ll probably want
\\\\wsl$\\Ubuntu-18.04\\home\\moose
. The name after thewsl$
pseudotarget needs to match the distribution name.+1 In version: 0.3.2171.0 startingDirectory is not respected. Strictly defaults to %USERPROFILE% where I want “~” for default wsl.exe shells.
I think we can let
wt.exe
have a command line optionand use that path for the starting directory, otherwise respecting the profile settings. This way you can type
wt.exe -p .
and get the behavior you want. We probably should also have a look at how terminal emulators on other platforms behave in this aspect, but I think gnome-terminal always launches the shell in my home directory…I don’t think having 2 different behaviors depending on whether the parent process is
cmd.exe
,explorer.exe
or some other is a good thing becausewt.exe
from msys2 bash, cygwin bash or any other alternative shell of which we would have to maintain a list that can never be exhaustive.(Plus, I guess since Start now has its own process
StartMenuExperienceHost.exe
, the actual parent of the processes launched from Start will be that process instead?)I’m here from this issue https://github.com/microsoft/terminal/issues/11544
I think it’s important to make this command tool compatible with the entire command line ecosystem. In a shell,
wt -d .
should be replaced bywt .
(like for cmd) In the navigation bar,wt
should open the terminal in the current directory (like for cmd)Oh my. Sorry for wasting everyone’s time. You can go ahead and delete this waste of space.
My profile has
"commandline": "wsl.exe -d Ubuntu"
. I expect it to start in$HOME
aka~
and not in/mnt/c/Windows/SYSTEM32
.Know that
startingDirectory
is not set for this profile. That is how the profile was created when installed on my machine.I am using the current store version: 0.2.1715.0
This must be an annoying issue, seeing how many people fail to find it and get’s repeated over and over.
😃 Maybe Windows could provide an API to solve this issue and it may be even useful to many other applications.
That’s not exactly true. The problem here is that
startingDirectory
is a windows path.Great solution! Maybe the the
-p
parameter can also be used as the default (unnamed) parameter. That way we can even usewt.exe .
. Which looks like the workflow many apps use (explorer .
,code .
)Totally agreed. The solution you mentioned (
-p
) is simple and predictable.Run: wt.reg
Sure:
None of the things proposed here work any longer.
which is in the default Debian profile, actually leads me to a totally different predefined path:
/mnt/c/Users/<WindowsUser>
. I want my Linux home directory, not my Windows home directory.PS: I tried the full Windows path to where the Debian home directory is stored, properly escaping it, and that lead me to Debian’s root directory and no further than that.
What I am used to be doing is going through directories in total commander, when in right spot typing “cmd” or “Powershell” to open a cmd line to run some commands. The same way I used to switch between cmd, Powershell or bash. I know these are shells, and this is terminal - however, in the end, all these are “windows where you can type in commands” 😃. Need to type anything extra would make terminal work differently to how it currently works in cmd, bash or Powershell.
For the benefit of people looking like me for how this can be worked around for now: You need to remove
"startingDirectory" : "%USERPROFILE%",
fromprofiles.json
and thenwt
will start in the directory you are in. [I have version 0.4.2382.0]This workaround no longer seems to be functioning with the latest update. The issue however still remains.
(When I say latest update, I am referring to the build available via the MSFT store.)