是否可以将用户设置配置为使集成终端在打开Visual Studio代码时自动启动?
发布于 2020-06-26 21:22:21
现在有了一个扩展,可以让你在启动时设置终端,甚至可以使用拆分终端视图!
https://marketplace.visualstudio.com/items?itemName=EthanSK.restore-terminals
附言:我写的
发布于 2020-05-14 08:54:45
从VSCodev1.45.0开始,this other answer中提到的实验配置现在应该是VS的默认行为。只需确保将文件/文件夹保存在工作区中即可。请参阅VS代码文档的What is a VS Code "workspace"?部分。
VS Code记住工作区的最后状态并将其还原。如果我在关闭窗口之前打开了集成终端面板,当我重新加载或重新打开工作区时,它会重新打开(但我似乎找不到这样的设置)。因此,基本上,集成终端已经自动显示。(我使用Ubuntu18和macOS 10.15。)
如果您有特定的终端设置(例如多个终端打开到不同的目录、python环境、工作区等),您可以查看Terminals Manager,它用于“一次设置多个终端”,并且可以配置为在启动时自动运行。
您只需要在您的工作区(在.vscode下)中添加一个terminals.json文件,并将autorun设置为true。这将自动运行扩展的终端:在启动时运行命令以自动加载您的终端。
{
"autorun": true,
"autokill": true,
"terminals": [
{
"name": "GIT",
"description": "For running git commands",
"open": true,
"focus": true,
"commands": [
"pwd",
"git fetch -v"
]
},
{
"name": "BUILD",
"description": "For running build commands",
"open": true,
"focus": false,
"commands": [
"cd apps",
"./clean.sh"
]
},
{
"name": "SCRIPTS",
"description": "For running python commands",
"open": true,
"focus": false,
"commands": [
"source $VENV_DIR/test-py38/bin/activate",
"python -V"
]
},
]
}发布于 2018-08-14 07:16:50
下面的方法对我很有效:
//启动VS Code时是否自动恢复工作区的终端会话这是一个试验性的设置;它可能是错误的,并且在未来可能会改变。
在您的用户设置中粘贴以下内容:
"terminal.integrated.experimentalRestore":true
https://stackoverflow.com/questions/45957618
复制相似问题