简体   繁体   中英

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.

尝试使用wsl.exe作为 shell 命令。

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

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 (eg 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? (eg git bash or MinGW bash?)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM