Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio code 在VSCode终端中将WSL设置为CWD_Visual Studio Code_Vscode Settings_Windows Subsystem For Linux - Fatal编程技术网

Visual studio code 在VSCode终端中将WSL设置为CWD

Visual studio code 在VSCode终端中将WSL设置为CWD,visual-studio-code,vscode-settings,windows-subsystem-for-linux,Visual Studio Code,Vscode Settings,Windows Subsystem For Linux,我已经在我的Windows10机器上安装了ubuntu,并且一直在使用vscode。我想使用wsl集成终端。如果我只打开vscode,然后打开一个新的wsl终端,它将显示我的路径: username@Computer:/mnt/c/Users/winusername 如果我打开一个项目文件夹(不是工作区),然后打开一个新的终端,它会显示为: username@Computer:~ 这不在我的项目文件夹位置-是否有办法让wsl集成终端将项目位置设置为当前工作目录 如果我将Git bash用作我的终

我已经在我的Windows10机器上安装了ubuntu,并且一直在使用vscode。我想使用wsl集成终端。如果我只打开vscode,然后打开一个新的wsl终端,它将显示我的路径:
username@Computer:/mnt/c/Users/winusername

如果我打开一个项目文件夹(不是工作区),然后打开一个新的终端,它会显示为:
username@Computer:~

这不在我的项目文件夹位置-是否有办法让wsl集成终端将项目位置设置为当前工作目录

如果我将Git bash用作我的终端,它可以很好地实现这一点,如下所示:

winusername@ComputerMINGW64/d/my/project/path


但是我想使用wsl。

我认为您的配置有点不正确

检查有关用户设置和工作区设置的终端配置

您可以在UI上找到一种简单的方法

  • 文件>首选项>设置

  • 检查默认的“集成终端”路径和
    cwd

    在我的例子中,对默认终端使用
    wsl.exe
    ,而不是
    bash.exe

  • 与用户界面上方的
    用户设置
    工作区设置
    比较,选项键大致相同。(点击标题即可轻松进行比较)

  • 如果您的设置没有问题,我建议使用此VSCODE扩展。 它有助于打开带有已打开文件的路径的终端


  • 我像这样编辑了我的
    设置。json
    ,它确实起了作用:

    "terminal.integrated.shell.windows": "${fullPathToExecutable}",
    "terminal.integrated.shellArgs.windows": ["run"],
    "terminal.integrated.cwd": "C:\\Users\\winusername"
    

    你的项目文件夹在哪里;在wsl中还是在Windows中?vscode安装在wsl或Windows的何处?您是否添加了tasks.json或settings.json?windows中有哪个项目C/C++?@Biswapriyo项目文件夹,以及vscode安装。未添加任何tasks.json或settings.json。项目类型是python和简单的编辑(标记、AWS CFN模板、docker文件等),我认为它是重复的版本,并在这里简要说明