更改 Visual Studio Code 集成终端的默认路径 [英] Changing the default path of Visual Studio Code's integrated terminal

查看:95
本文介绍了更改 Visual Studio Code 集成终端的默认路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改 Visual Studio Code 中集成终端的默认路径,但我不确定如何更改.我知道如何在 Windows 命令提示符中更改它,但不知道如何在 Visual Studio Code 中更改它.我查看了用户设置,但找不到任何可以更改的内容.

I'm trying to change the default path of the integrated terminal in Visual Studio Code, but I'm not sure how to. I do know how to change it in the windows command prompt, but not in Visual Studio Code. I looked in user settings, but I can't find anything there to change.

当前默认路径为C:\Users\User_Name.

我想将其更改为 C:\Project.

如何在 Visual Studio Code 中执行此操作?

How do I do this in Visual Studio Code?

推荐答案

简短回答

编辑用户首选项 "terminal.integrated.cwd": "" 到您希望集成终端打开的路径.

Short answer

Edit the user preference "terminal.integrated.cwd": "" to the path that you want the integrated terminal to open to.


相同的答案,但详细的分步版本,

The same answer, but the long step-by-step version,

在 Visual Studio Code 中转到:

In Visual Studio Code go to:

菜单文件首选项设置

Menu FilePreferencesSettings


现在您已进入用户设置",使用窗口顶部的搜索设置"栏粘贴或输入:


Now that you are in the "User Settings", using the "Search Settings" bar across the top of the window paste or type this:

terminal.integrated.cwd

terminal.integrated.cwd


结果将列出以下内容:


It will list the following as a result:

// 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": "",


您会注意到它不会让您在此处键入以更改此设置.那是因为您无法更改默认设置.您需要更改您的个人设置.方法如下...


点击此选项左侧的铅笔图标,然后点击弹出的复制到设置"选项.


Click the pencil icon to the left of the this option and then the "Copy to Settings" option that pops-up.


您应该有一个分屏,其中屏幕右侧有标题将您的设置放在此处以覆盖默认设置. 这是您进行更改的正确位置.您可能已经在此处列出了一些个性化设置.


You should have a split screen in which the right side of the screen has the heading Place your settings here to overwrite the Default Settings. This is the correct place for you to make changes. You might already have a few personalized settings listed here.


当您单击复制到设置"时,它会自动为您添加此行:


When you clicked "Copy to Settings" it automatically added this line for you:

"terminal.integrated.cwd": ""

"terminal.integrated.cwd": ""

请注意,此列表中的最后一项将不会有尾随逗号,但列表中它之前的任何项目都需要一个.

Notice that whichever item is last in this list will not have a trailing comma but any items before it in the list will require one.

仅供参考:您可以自己简单地将其输入或复制/粘贴到个性化设置中,但遵循这些步骤是学习根据需要更改其他首选项的过程.


现在您可以键入以设置要使用的路径.确保使用 \\ 代替 \ 并且不需要尾随 \.例如,包含这一行将始终在 baz 目录中启动您的终端:


Now you are able to type to set the path you want to use. Make sure to use \\ in place of \ and you do not need the trailing \. For example including this line would always start your terminal in the baz directory:

{
    "terminal.integrated.cwd": "C:\\Users\\foo\\bar\\baz"
}


要应用更改,只需保存重新启动 Visual Studio Code.

这篇关于更改 Visual Studio Code 集成终端的默认路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆