Trying to write an extension that executes the terminal command.
For example:
if I execute the sensors
command in the terminal, it will show the CPU temperature. I want to create a command that prints this information into the terminal upon activation.
I have tried by placing it with registercommand like following.
let d = vscode.commands.registerCommand(sensors);
context.subscriptions.push(d);
Does anyone know where to put these type of terminal commands?
Environment:
Ubuntu 22.04.1 LTS
AMD Ryzen 3
2
Answers
Used child_process to execute the terminal command from extension (One click output)
One possible approach is to use Node.js’ child_process module, run the sensor command in a separate process with this, read the output and print that in an output channel in VS Code.