Reputation: 5811
After a task completes, the terminal will stay open. Is there anyway to auto hide it?
I am not talking about closing the window as described at https://code.visualstudio.com/updates/v1_57#_automatically-close-task-terminals because that will remove all the output.
I only want to hide the Terminal so that I can still go back to the output if I need it by opening the Terminal panel.
Upvotes: 3
Views: 4468
Reputation: 180695
Hopefully there is a better way that I don't know of but this works. Make these tasks in your tasks.json
:
{
"version": "2.0.0",
"tasks": [
{
"label": "echo and hide",
"dependsOrder": "sequence",
"dependsOn": [
"simple echo",
"hide terminal"
]
},
{
"label": "simple echo",
"command": "echo I have been hidden",
"type": "shell",
"problemMatcher": []
},
{
"label": "hide terminal",
"command": "${command:workbench.action.togglePanel}",
"type": "shell",
"problemMatcher": []
}
]
}
And you would run the "echo and hide" task which would run the task you really want first and then run the task with the command ${command:workbench.action.togglePanel}
in it to hide the Panel (assuming that is where your Terminal is).
Unfortunately, what you can't do is this:
"command": "echo 'I have been hidden' && ${command:workbench.action.togglePanel}"
it doesn't seem to work.
Alternatively, look at the presentation properties:
{
"label": "simple echo",
"command": "echo I have been hidden",
"type": "shell",
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "silent", // <== open only on problems
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
This will not open the Terminal if it is closed (unless there are problems with the task). But it will not hide a Terminal that is already open when you run the task. If you want the Terminal to always hide when you run a task you may have to look at the first option of dependent tasks.
Upvotes: 6