开始构建时如何自动清除VS Code终端? [英] How do I automatically clear VS Code terminal when starting a build?

查看:995
本文介绍了开始构建时如何自动清除VS Code终端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按 Ctrl + Shift + B Visual Studio Code 开始构建(已配置为只需运行GNU Make),然后将构建工具的输出写入终端"窗口.

I press Ctrl+Shift+B to start a build in Visual Studio Code (it's configured to just run GNU Make), and the build tool output is written to the Terminal window.

但是,它被附加到先前版本的输出中,这很令人困惑.

However, it's appended to the output from the previous build, which is confusing.

在开始新版本之前,如何配置VS Code以清除终端窗口?

How do I configure VS Code to clear the terminal window before starting a new build?

推荐答案

2018年11月更新

截至此提交(以及一些后续后续操作),您可以现在在您的任务中添加一个clear演示文稿选项,以使其在运行每个任务之前清除终端.

As of this commit (and a few subsequent follow-ups), you can now add a clear presentation option to your task to have it clear the terminal before each task run.

工作示例(在新的clone + build上):

Working example (on fresh clone+build):

{
    // 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
            }
        }
    ]
}

(注意:链接的commit diff的密钥名为clearBeforeExecuting,但显然已更改为clear).

(Note: the linked commit diff has the key being named clearBeforeExecuting but it's apparently since been changed to just clear).

在此之前,我使用以下命令在路径上创建了clear_g++脚本:

Prior to this, I created a clear_g++ script on my path with just:

#!/bin/bash
clear
exec g++ $*

并将我的commandg++更改为clear_g++.

因为我喜欢这种方法的想法,但最终没有奏效.

Since I liked the idea of this approach but it didn't end up working out.

这篇关于开始构建时如何自动清除VS Code终端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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