mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
@ -12,3 +12,8 @@ Several commands are exposed prefixed with "Terminal API" that show how to use t
|
||||
- `Terminal API: Send Text`: Sends `echo "Hello World!"` to the terminal
|
||||
- `Terminal API: Send Text (no implied \n)`: Sends `echo "Hello World!"` to the terminal explicitly indicating to not add a `\n` to the end of the text
|
||||
- `Terminal API: Dispose`: Disposes the most recently created terminal
|
||||
|
||||
Coming in v1.6.0:
|
||||
|
||||
- `Create Terminal (zsh login shell) [v1.6+]`: Creates a terminal using shell path and args set by extension
|
||||
- `Terminal API: Write process ID to console [v1.6+]`: Uses Terminal.processId to get the shell's process ID
|
||||
@ -44,6 +44,9 @@
|
||||
}, {
|
||||
"command": "terminalTest.createZshLoginShell",
|
||||
"title": "Terminal API: Create Terminal (zsh login shell) [v1.6+]"
|
||||
}, {
|
||||
"command": "terminalTest.processId",
|
||||
"title": "Terminal API: Write process ID to console [v1.6+]"
|
||||
}]
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@ -54,9 +54,16 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
context.subscriptions.push(vscode.commands.registerCommand('terminalTest.createZshLoginShell', () => {
|
||||
terminalStack.push((<any>vscode.window).createTerminal(`Ext Terminal #${terminalStack.length + 1}`, '/bin/zsh', ['-l']));
|
||||
}));
|
||||
(<any>vscode.window).onDidCloseTerminal((terminal) => {
|
||||
console.log('Terminal closed', terminal);
|
||||
});
|
||||
context.subscriptions.push(vscode.commands.registerCommand('terminalTest.processId', () => {
|
||||
(<any>getLatestTerminal()).processId.then((processId) => {
|
||||
console.log(`Shell process ID: ${processId}`);
|
||||
});
|
||||
}));
|
||||
if ('onDidCloseTerminal' in <any>vscode.window) {
|
||||
(<any>vscode.window).onDidCloseTerminal((terminal) => {
|
||||
console.log('Terminal closed', terminal);
|
||||
});
|
||||
}
|
||||
|
||||
function getLatestTerminal() {
|
||||
return terminalStack[terminalStack.length - 1];
|
||||
|
||||
Reference in New Issue
Block a user