首页 > 解决方案 > 更改 VS Code 终端的默认工作目录

问题描述

是否可以在 Visual Studio Code 中更改新集成终端窗口的工作目录?

我已经/path/to/project在 Code 中打开了该文件夹,因此当我打开一个新的终端窗口时,它会在该文件夹中启动。我希望终端打开,/path/to/project/app这样我就不必每次都cd到那个文件夹。是否可以在其中进行配置settings.json

标签: visual-studio-code

解决方案


事实证明,这在https://code.visualstudio.com/docs/getstarted/settings的文档中很容易找到。

控制这个的设置是

  // An explicit start path where the terminal will be launched, this is used
as the current working directory (cwd) for the shell process. This may be
particularly useful in workspace settings if the root directory is not a convenient cwd.
  "terminal.integrated.cwd": "",

这可以添加到settings.json文件.vscode夹中。支持绝对路径和相对路径,因此

"terminal.integrated.cwd": "app"

"terminal.integrated.cwd": "/path/to/project/app"

两者都可以。


推荐阅读