Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I automatically clear VS Code terminal when starting a build?

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.

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

like image 414
Roger Lipscombe Avatar asked Sep 14 '17 14:09

Roger Lipscombe


People also ask

How do you auto complete in VS Code?

You can trigger IntelliSense in any editor window by typing Ctrl+Space or by typing a trigger character (such as the dot character (.) in JavaScript).

How do I clear the Output window in Visual Studio?

printf("\f"); will print a form feed to the console. That is supposed to clear it.


1 Answers

November 2018 Update

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.

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

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

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

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

And changed my command from g++ to clear_g++.

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

like image 107
jedwards Avatar answered Sep 22 '22 20:09

jedwards