From 57895611e84269c578f6502d2086398063a784a0 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Mon, 10 Jul 2017 12:02:25 -0700 Subject: [PATCH 1/2] Add setting for passing env var to terminal. #14973 --- .../workbench/parts/terminal/common/terminal.ts | 1 + .../electron-browser/terminal.contribution.ts | 15 +++++++++++++++ .../terminal/electron-browser/terminalInstance.ts | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/parts/terminal/common/terminal.ts b/src/vs/workbench/parts/terminal/common/terminal.ts index 449cf29d2fc..e4e393852fa 100644 --- a/src/vs/workbench/parts/terminal/common/terminal.ts +++ b/src/vs/workbench/parts/terminal/common/terminal.ts @@ -67,6 +67,7 @@ export interface ITerminalConfiguration { commandsToSkipShell: string[]; cwd: string; confirmOnExit: boolean; + envVars: object; } export interface ITerminalConfigHelper { diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts index 3995aacb60c..ef8a76358aa 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts @@ -197,6 +197,21 @@ configurationRegistry.registerConfiguration({ DeleteWordLeftTerminalAction.ID, DeleteWordRightTerminalAction.ID ].sort() + }, + 'terminal.integrated.envVars.osx': { + 'description': nls.localize('terminal.integrated.envVars.osx', "Object with environment variables that will be passed to the terminal on OS X"), + 'type': 'object', + 'default': {} + }, + 'terminal.integrated.envVars.linux': { + 'description': nls.localize('terminal.integrated.envVars.linux', "Object with environment variables that will be passed to the terminal on Linux"), + 'type': 'object', + 'default': {} + }, + 'terminal.integrated.envVars.windows': { + 'description': nls.localize('terminal.integrated.envVars.windows', "Object with environment variables that will be passed to the terminal on Windows"), + 'type': 'object', + 'default': {} } } }); diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index bd1c9448be5..7738e81cb3d 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -511,7 +511,9 @@ export class TerminalInstance implements ITerminalInstance { this._configHelper.mergeDefaultShellPathAndArgs(shell); } this._initialCwd = this._getCwd(this._shellLaunchConfig, this._historyService.getLastActiveWorkspaceRoot()); - const env = TerminalInstance.createTerminalEnv(process.env, shell, this._initialCwd, locale, this._cols, this._rows); + const platformKey = platform.isWindows ? 'windows' : platform.isMacintosh ? 'osx' : 'linux'; + const envFromConfig = { ...process.env, ...this._configHelper.config.envVars[platformKey] }; + const env = TerminalInstance.createTerminalEnv(envFromConfig, shell, this._initialCwd, locale, this._cols, this._rows); this._title = shell.name || ''; this._process = cp.fork(Uri.parse(require.toUrl('bootstrap')).fsPath, ['--type=terminal'], { env, From 848c655be762d28273c1ce04bec145ebecb0210e Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Mon, 10 Jul 2017 14:05:45 -0700 Subject: [PATCH 2/2] Update desc and strong type terminal env setting #14973 --- src/vs/workbench/parts/terminal/common/terminal.ts | 6 +++++- .../electron-browser/terminal.contribution.ts | 12 ++++++------ .../terminal/electron-browser/terminalInstance.ts | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/parts/terminal/common/terminal.ts b/src/vs/workbench/parts/terminal/common/terminal.ts index e4e393852fa..3b92d8d0dc3 100644 --- a/src/vs/workbench/parts/terminal/common/terminal.ts +++ b/src/vs/workbench/parts/terminal/common/terminal.ts @@ -67,7 +67,11 @@ export interface ITerminalConfiguration { commandsToSkipShell: string[]; cwd: string; confirmOnExit: boolean; - envVars: object; + env: { + linux: { [key: string]: string }; + osx: { [key: string]: string }; + windows: { [key: string]: string }; + }; } export interface ITerminalConfigHelper { diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts index ef8a76358aa..1759c679e1d 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts @@ -198,18 +198,18 @@ configurationRegistry.registerConfiguration({ DeleteWordRightTerminalAction.ID ].sort() }, - 'terminal.integrated.envVars.osx': { - 'description': nls.localize('terminal.integrated.envVars.osx', "Object with environment variables that will be passed to the terminal on OS X"), + 'terminal.integrated.env.osx': { + 'description': nls.localize('terminal.integrated.env.osx', "Object with environment variables that will be added to the VS Code process to be used by the terminal on OS X"), 'type': 'object', 'default': {} }, - 'terminal.integrated.envVars.linux': { - 'description': nls.localize('terminal.integrated.envVars.linux', "Object with environment variables that will be passed to the terminal on Linux"), + 'terminal.integrated.env.linux': { + 'description': nls.localize('terminal.integrated.env.linux', "Object with environment variables that will be added to the VS Code process to be used by the terminal on Linux"), 'type': 'object', 'default': {} }, - 'terminal.integrated.envVars.windows': { - 'description': nls.localize('terminal.integrated.envVars.windows', "Object with environment variables that will be passed to the terminal on Windows"), + 'terminal.integrated.env.windows': { + 'description': nls.localize('terminal.integrated.env.windows', "Object with environment variables that will be added to the VS Code process to be used by the terminal on Windows"), 'type': 'object', 'default': {} } diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index 7738e81cb3d..39101b427dd 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -512,7 +512,7 @@ export class TerminalInstance implements ITerminalInstance { } this._initialCwd = this._getCwd(this._shellLaunchConfig, this._historyService.getLastActiveWorkspaceRoot()); const platformKey = platform.isWindows ? 'windows' : platform.isMacintosh ? 'osx' : 'linux'; - const envFromConfig = { ...process.env, ...this._configHelper.config.envVars[platformKey] }; + const envFromConfig = { ...process.env, ...this._configHelper.config.env[platformKey] }; const env = TerminalInstance.createTerminalEnv(envFromConfig, shell, this._initialCwd, locale, this._cols, this._rows); this._title = shell.name || ''; this._process = cp.fork(Uri.parse(require.toUrl('bootstrap')).fsPath, ['--type=terminal'], {