Nolence
Nolence

Reputation: 2254

Have WSL shell open to project directory in Windows Visual Studio Code

I have a windows subsystem for Linux Installed on my computer and am using it as the integrated terminal on Visual Studio Code. Every time I open a terminal however, it opens in the root directory rather than the current project directory like other terminals do.

Does anyone know of a fix for this?

I have tried messing with the Cwd of the integrated terminal settings but haven't had any luck.

Upvotes: 2

Views: 3094

Answers (2)

Adrian L.L.
Adrian L.L.

Reputation: 16

I know that is very late for this answer, but for me it just worked. I put exactly as above and it launched in my home directory (that is /mnt/d/Users/Adrian).

I have the user setup of VSC, 1.30.1 and launch it from the Desktop shortcut. After I configured terminal as wsl I go as below: If I open a cmd windows I can launch it with code . it will launch in Windows home directory. If move to some other folder (e.g Documents) and launch it with code . the bash will launch to that folder. Otherwise I can launch it with code D:\Users\Adrian\Documents\VSC and the bash terminal will launch in \mnt\D\Users\Adrian\Documents\VSC

Tested the change both via menu File->Preferences->Settings and with Ctrl+Shift+P (Command Pallete), Terminal: Default Shell.

Tried with bash and wsl.

Maybe you have some other bash installed in the path? (e.g. git bash or MinGW bash?)

Upvotes: -1

user10668137
user10668137

Reputation:

Try using wsl.exe as the command for shell.

"terminal.integrated.shell.windows": "wsl.exe"

Upvotes: 2

Related Questions