Merge pull request #30349 from Microsoft/ramyar/terminal-env-var

Add setting for passing env var to terminal.
This commit is contained in:
Daniel Imms
2017-07-10 14:49:39 -07:00
committed by GitHub
3 changed files with 23 additions and 1 deletions
@@ -67,6 +67,11 @@ export interface ITerminalConfiguration {
commandsToSkipShell: string[];
cwd: string;
confirmOnExit: boolean;
env: {
linux: { [key: string]: string };
osx: { [key: string]: string };
windows: { [key: string]: string };
};
}
export interface ITerminalConfigHelper {
@@ -197,6 +197,21 @@ configurationRegistry.registerConfiguration({
DeleteWordLeftTerminalAction.ID,
DeleteWordRightTerminalAction.ID
].sort()
},
'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.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.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': {}
}
}
});
@@ -516,7 +516,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.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'], {
env,