visual-studio-code - 如何在开始构建时自动清除 VS Code 终端?

标签 visual-studio-code vscode-tasks

我按 Ctrl+Shift+BVisual 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/

相关文章:

visual-studio-code - "winget install vscode"缺少包

java - VS Code Java 调试器参数

visual-studio-code - Visual Studio Code 中每个工作区的 keybindings.json

visual-studio-code - 在 vscode for WSL 中的 task.json 中设置环境变量

linux - vscode 总是请求保存权限

azure - 目前,在 VS Code 中,我的 Azure 资源仅显示 Functions App 而没有其他内容(例如,它应该显示的其他内容是 Cosmos DB、VM)

visual-studio-code - 显示行以 vscode 结尾

c++ - 如何在windows上使用cl.exe定义task.json来在vscode中编译C/C++代码?

c# - 如何在 vscode 中访问 tasks.json 中的 .env 变量?

javascript - 在 VSCode 中禁用 Javascript 的特定错误消息?