我按 Ctrl+Shift+B 在 Visual Studio Code 中启动构建(它配置为只需运行 GNU Make),构建工具输出将写入终端窗口。
但是,它被附加到先前构建的输出中,这令人困惑。
如何配置 VS Code 以在开始新构建之前清除终端窗口?
最佳答案
2018 年 11 月更新
截至this commit (以及一些后续的后续操作),您现在可以向您的任务添加一个 clear
演示选项,以便在每个任务运行之前清除终端。
工作示例(在新的克隆+构建上):
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "[gcc] Build",
"type": "shell",
"command": "g++",
"args": [
"source.h",
"-Wall",
"-o",
"a.out"
],
"presentation": {
"clear": true // <-- this line
}
}
]
}
(注意:链接的提交差异的 key 名为 clearBeforeExecuting
,但显然已更改为 clear
)。
在此之前,我在路径上创建了一个 clear_g++
脚本:
#!/bin/bash
clear
exec g++ $*
并将我的命令
从g++
更改为clear_g++
。
因为我喜欢this approach的想法但最终并没有成功。
关于visual-studio-code - 如何在开始构建时自动清除 VS Code 终端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46221272/