VSCode has a Windows API that allows interaction with the terminal.
For example, you can send the Linux command pwd
& the command output may be /usr/home/userName
I have tried writing the output to disk & then reading it later by using something like pwd > directory.txt
;
terminal.sendText(`pwd > directory.txt`);
This seems to work, but I was wondering if there was something more elegant.
//Create a new terminal
let terminal = vscode.window.createTerminal(`Name of terminal`, 'C:\path\to\terminal\shell\shell.exe');
// send command to newly created terminal
terminal.sendText(`pwd`);
I know for sure the code above works because I can write the outputs to a file using;
terminal.sendText(`pwd > directory.txt`);
So the question is, how do I get the outputs of terminal.sendText()
as a string without having to first write them to disk?