From e6bac737f52e6dfbac98f16072b611f4b9aef81d Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 19 Sep 2016 14:35:52 -0700 Subject: [PATCH] Add Terminal.processId example Part of Microsoft/vscode#11919 --- terminal-example/README.md | 5 +++++ terminal-example/package.json | 3 +++ terminal-example/src/extension.ts | 13 ++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/terminal-example/README.md b/terminal-example/README.md index 0b056249..7868d414 100644 --- a/terminal-example/README.md +++ b/terminal-example/README.md @@ -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 \ No newline at end of file diff --git a/terminal-example/package.json b/terminal-example/package.json index 12b44fea..568ade6f 100644 --- a/terminal-example/package.json +++ b/terminal-example/package.json @@ -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": { diff --git a/terminal-example/src/extension.ts b/terminal-example/src/extension.ts index 648aa262..8a135896 100644 --- a/terminal-example/src/extension.ts +++ b/terminal-example/src/extension.ts @@ -54,9 +54,16 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(vscode.commands.registerCommand('terminalTest.createZshLoginShell', () => { terminalStack.push((vscode.window).createTerminal(`Ext Terminal #${terminalStack.length + 1}`, '/bin/zsh', ['-l'])); })); - (vscode.window).onDidCloseTerminal((terminal) => { - console.log('Terminal closed', terminal); - }); + context.subscriptions.push(vscode.commands.registerCommand('terminalTest.processId', () => { + (getLatestTerminal()).processId.then((processId) => { + console.log(`Shell process ID: ${processId}`); + }); + })); + if ('onDidCloseTerminal' in vscode.window) { + (vscode.window).onDidCloseTerminal((terminal) => { + console.log('Terminal closed', terminal); + }); + } function getLatestTerminal() { return terminalStack[terminalStack.length - 1];