For an overview of all types of shells used in Visual Studio Code, see this answer https://stackoverflow.com/a/60555493/45375.
Custom shell profiles are maintained in the settings.json
file; to open it for editing, select Preferences: Open Settings (JSON)
from the command palette (Ctrl-Shift-P).
有特定于平台的属性命名为terminal.integrated.profiles.*
, where *
或者是windows
, linux
, or osx
(苹果系统)。
The properties inside each define shell profiles, i.e. the shells available for running in the integrated terminal via the dropdown menu labeled +
().
Each 外壳配置文件定义:
-
至少需要一个path
参数指定 shell 可执行文件的完整路径,或者仅在 Windows 上source
论证,可以是PowerShell
or Git Bash
让 VS Code 找到合适的可执行文件。
-
启动参数通过指定args
.
-
有关所有支持的属性,请参阅the docs https://code.visualstudio.com/docs/editor/integrated-terminal#_configuring-profiles.
To set the default外壳轮廓:
示例:定义 Node.js (node.exe
) 作为 Windows 上的自定义 shell 配置文件:
- 确定完整路径
node.exe
并逃脱\
JSON 的字符加倍;例如,从 PowerShell:
# Get node.exe's full path, escape '\' chars., copy to the clipboard.
(Get-Command node.exe).Path.Replace('\', '\\') | Set-Clipboard
- 将以下内容添加到您的
settings.json
文件(如果terminal.integrated.profiles.windows
财产已经存在,简单地说add the Node.js
其财产);该示例使用node.exe
的默认安装位置,C:\Program Files\nodejs\node.exe
.
"terminal.integrated.profiles.windows": {
"Node.js": {
"path": "C:\\Program Files\\nodejs\\node.exe",
"args": [] // Add startup arguments as needed.
}
},
// Make Node.js the default shell (if the property already exists, update its value).
"terminal.integrated.defaultProfile.windows": "Node.js",