1

For various windows terminal profiles it seems to be possible to open up a new shell in the directory the shell has been opened with. (e.g. context menu option "Open in Terminal"), for WSL on the other hand it seems to be difficult to configure

You are able to set your wt start path by passing a "cd" arg to the wsl execution. I found that out here

I wasnt able to provide the cd arg with my current directory though. I tried to pass it the %cd% env var, the simple and classy dot, but without success.

"commandline": "wsl --cd %cd%", "commandline": "wsl --cd .",

I also found this post that tells me that there is a built in tool that can convert paths to and from WSL. I thought this might be useful to convert the current path to a WSL one and provide in in the "startingDirectory": "X", property, as this one only accepts WSL paths as input.

I know that its possible to immediately go to the directory the shell has been opened with, because this functionality already exists when you do a Shift + open context menu (right mouse click) and select the option "Open Linux shell here". This only opens the shell in a seperate wsl window though, not in windows terminal.

2
  • I am confused by your question and don't understand EXACTLY what you are trying to accomplish. wt wsl from cmd.exe opens terminal/bash in whatever directory I was in. Please describe in detail what you are trying to do. Yes, there are plenty of tricks to get a converted path.. I just don't understand where you are trying to use one. Commented Dec 15, 2022 at 16:55
  • i wanna open up wt with wsl and also have the feature to open the dir i am in, this doesnt work for me
    – Platinium
    Commented Dec 17, 2022 at 9:45

1 Answer 1

1

found the solution, per default (when ubuntu is installed) there are 2 wt profiles. one with the ubuntu symbol and one with the linux penguin. the ubuntu launch setting starts the ubuntu.exe in path. The Wsl launch setting (the penguin) starts C:\WINDOWS\system32\wsl.exe -d Ubuntu

I only solved this for the Wsl lauch setting, yet.

if you remove the -d Ubuntu wsl will start in the directory the shell was lauched in. So your windows terminal settings for the wsl profile should look like this for the "Command line" property. C:\WINDOWS\system32\wsl.exe

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .