Vscode: Task>Presentation should allow to clear the terminal output.

Created on 3 Jul 2017  路  24Comments  路  Source: microsoft/vscode

feature-request help wanted tasks verification-needed verified

Most helpful comment

Does this issue refer to automatically clearing the terminal output when a task begins? I've been searching for a way to do that.

All 24 comments

Does this issue refer to automatically clearing the terminal output when a task begins? I've been searching for a way to do that.

Yes, this is the feature request.

I really wish this was a thing.

+1

+1

+1

Hi,
One way to do that is to add clear command before actual task command like below.
"command": "clear;ninja",
I'm using tcsh shell and ninja to build.
Regards,
Mat

Does not work for me, VSCode on Win10.

Windows doesn't have clear command, but you can try cls:
"command": "cls;ninja",

No luck neither :(

Terminal will be reused by tasks, press any key to close it.

> Executing task in folder cobalt.rs: cls;cargo check <

It works for me by just adding a "clear" command before my real task command. Like this

      "command":[
        "clear;",
        "clang++ -g -O0 a.cpp"
      ],

Do NOT miss the semicolon after "clear"

Still no luck on Windows 10. using 1.25.

Funny enough, without the the semicolon, I lose all the command output:

> Executing task: cls cargo check <

Terminal will be reused by tasks, press any key to close it.

@Geobert Try using WSL. The workaround will work there (on Linux side ofc) plus plenty of benefits to using it.

I can't, Win 7 :(

+1

I've tried so many workarounds for this it is starting to wear me out. Even a build task that depends on another task that clears the terminal doesn't work. I suppose because clearing uses "type": "process" and my gcc build task uses "type": "shell". I am either stuck periodically deleting all the new terminal instances created for each build or spending time figuring out where output of latest build ends and old one begins.

Any progress on the issue? Any workaround working on Windows 10?

As always a PR will help to speed things up.

cls command in task runner does not work. I dont like scrolling to the bottom to check the error messages.

+1 Also looking for this functionality.

@alexr00 This would actually be a good first feature-request. Only limited changes.

As a workaround, try creating a composite task, where the actual task you want to execute depends on the task to clear the terminal. For example:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "clear terminal",
      "type": "shell",
      "command":"clear",
      "presentation": {
        "echo": false,
        "reveal": "always",
        "focus": false,
        "panel": "shared",
        "showReuseMessage": false
      }
    },
    {
      "label": "mix test",
      "dependsOn":["clear terminal"],
      "type": "shell",
      "command":"mix",
      "args": ["test", "--color", "--trace"],
      "options": {
        "cwd": "${workspaceRoot}",
        "requireFiles": [
          "test/**/test_helper.exs",
          "test/**/*_test.exs"
        ],
      },
      "problemMatcher": "$mixTestFailure",
      "presentation": {
        "echo": false,
        "reveal": "always",
        "focus": false,
        "panel": "shared",
        "showReuseMessage": false
      }
    }
  ]
}

As a workaround, try creating a composite task, where the actual task you want to execute depends on the task to clear the terminal.

At first I thought it worked, but it only "hides above" the previous launch (at least on Windows). If you scroll up, you'll see the previous launches output

So it does. I hadn't noticed that. What's even more interesting is that if (in my example) I bin the Task - mix test terminal and run the task, then it only sometimes exhibits that behaviour, whilst at other times it "hides above".

For my example, it seems to be if I run a passing test suite then the behaviour is as I would expect, whether that is from the command pallet or a custom key binding. If I run a failing test suite at any time, it reverts to the "hide above" behaviour until I bin the terminal. I wonder why that would be?

Very frustrating. Is there perhaps a way to run a shell task, e.g. echo "" which takes the focus and then simulate a keypress to terminate the shell? This could then be run as a predecessor task. Or is there some way to execute the workbench.action.terminal.kill command from a task?

Another workaround, broadly similar to the above is to change the task to give the shell the focus. Rebind cmd+k or equivalent from workbench.action.terminal.clear to workbench.action.terminal.kill and then make this a step in the workflow (not great if the task runs for more than a second or so). It's another keypress but it's a step closer.

{
  "key": "cmd+k",
  "command": "workbench.action.terminal.kill"
}

At home with my gaming mouse (with buttons on thumb side), I've done this exactly:聽focus term, press space, run task. But at work I don't have such mouse ^^'

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sirius1024 picture sirius1024  路  3Comments

omidgolparvar picture omidgolparvar  路  3Comments

chrisdias picture chrisdias  路  3Comments

v-pavanp picture v-pavanp  路  3Comments

biij5698 picture biij5698  路  3Comments