Shell integration-powered capabilities owned by a terminal.
Variables
Methods
executeCommand(commandLine:String):TerminalShellExecution
executeCommand(executable:String, args:Array<String>):TerminalShellExecution
Execute a command, sending ^C as necessary to interrupt any running command if needed.
@example // Execute a command in a terminal immediately after being created const myTerm = window.createTerminal(); window.onDidChangeTerminalShellIntegration(async ({ terminal, shellIntegration }) => { if (terminal === myTerm) {
const execution = shellIntegration.executeCommand('echo "Hello world"');
window.onDidEndTerminalShellExecution(event => {
if (event.execution === execution) {
console.log(`Command exited with code ${event.exitCode}`);
}
});
} })); // Fallback to sendText if there is no shell integration within 3 seconds of launching setTimeout(() => { if (!myTerm.shellIntegration) {
myTerm.sendText('echo "Hello world"');
// Without shell integration, we can't know when the command has finished or what the
// exit code was.
} }, 3000);
@example // Send command to terminal that has been alive for a while const commandLine = 'echo "Hello world"'; if (term.shellIntegration) { const execution = shellIntegration.executeCommand({ commandLine }); window.onDidEndTerminalShellExecution(event => {
if (event.execution === execution) {
console.log(`Command exited with code ${event.exitCode}`);
}
}); } else { term.sendText(commandLine); // Without shell integration, we can't know when the command has finished or what the // exit code was. }
Parameters:
commandLine | The command line to execute, this is the exact text that will be sent to the terminal. |
---|