From 31bcb5ad38d9c376fd3ec6c3b3ca64273ceb00b0 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 8 Jun 2016 01:15:53 -0700 Subject: [PATCH] Add terminal shell args setting Fixes #7266 --- .../electron-browser/terminal.contribution.ts | 24 ++++++++++++++++++ .../terminal/electron-browser/terminal.ts | 5 ++++ .../electron-browser/terminalConfigHelper.ts | 25 ++++++++++++++----- .../electron-browser/terminalInstance.ts | 9 ++++--- .../electron-browser/terminalProcess.js | 15 +++++++++-- 5 files changed, 67 insertions(+), 11 deletions(-) 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 c04fc1edbc3..8ab26bc5920 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts @@ -28,16 +28,40 @@ configurationRegistry.registerConfiguration({ 'type': 'string', 'default': TERMINAL_DEFAULT_SHELL_LINUX }, + 'terminal.integrated.shellArgs.linux': { + 'description': nls.localize('terminal.integrated.shellArgs.linux', "The command line arguments to use when on the Linux terminal."), + 'type': 'array', + 'items': { + 'type': 'string' + }, + 'default': [] + }, 'terminal.integrated.shell.osx': { 'description': nls.localize('terminal.integrated.shell.osx', "The path of the shell that the terminal uses on OS X."), 'type': 'string', 'default': TERMINAL_DEFAULT_SHELL_OSX }, + 'terminal.integrated.shellArgs.osx': { + 'description': nls.localize('terminal.integrated.shellArgs.osx', "The command line arguments to use when on the OS X terminal."), + 'type': 'array', + 'items': { + 'type': 'string' + }, + 'default': [] + }, 'terminal.integrated.shell.windows': { 'description': nls.localize('terminal.integrated.shell.windows', "The path of the shell that the terminal uses on Windows."), 'type': 'string', 'default': TERMINAL_DEFAULT_SHELL_WINDOWS }, + 'terminal.integrated.shellArgs.windows': { + 'description': nls.localize('terminal.integrated.shellArgs.windows', "The command line arguments to use when on the Windows terminal."), + 'type': 'array', + 'items': { + 'type': 'string' + }, + 'default': [] + }, 'terminal.integrated.fontFamily': { 'description': nls.localize('terminal.integrated.fontFamily', "Controls the font family of the terminal, this defaults to editor.fontFamily's value."), 'type': 'string' diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts index e13afd46d09..508d4363650 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts @@ -27,6 +27,11 @@ export interface ITerminalConfiguration { osx: string, windows: string }, + shellArgs: { + linux: string[], + osx: string[], + windows: string[] + }, fontFamily: string, fontSize: number, lineHeight: number diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts index 81e140c304b..081e74ae5d0 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts @@ -76,6 +76,11 @@ export interface ITerminalFont { charHeight: number; } +export interface IShell { + executable: string; + args: string[]; +} + /** * Encapsulates terminal configuration logic, the primary purpose of this file is so that platform * specific test cases can be written. @@ -137,15 +142,23 @@ export class TerminalConfigHelper { return this.measureFont(fontFamily, fontSize, lineHeight); } - public getShell(): string { + public getShell(): IShell { let config = this.configurationService.getConfiguration(); + let shell: IShell = { + executable: '', + args: [] + }; if (this.platform === Platform.Windows) { - return config.terminal.integrated.shell.windows; - } - if (this.platform === Platform.Mac) { - return config.terminal.integrated.shell.osx; + shell.executable = config.terminal.integrated.shell.windows; + shell.args = config.terminal.integrated.shellArgs.windows; + } else if (this.platform === Platform.Mac) { + shell.executable = config.terminal.integrated.shell.osx; + shell.args = config.terminal.integrated.shellArgs.osx; + } else if (this.platform === Platform.Linux) { + shell.executable = config.terminal.integrated.shell.linux; + shell.args = config.terminal.integrated.shellArgs.linux; } - return config.terminal.integrated.shell.linux; + return shell; } private toInteger(source: any, minimum?: number): number { diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index 9e64b72ff9e..7eaa3e06986 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -17,7 +17,7 @@ import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {ITerminalService} from 'vs/workbench/parts/terminal/electron-browser/terminal'; import {DomScrollableElement} from 'vs/base/browser/ui/scrollbar/scrollableElement'; import {ScrollbarVisibility} from 'vs/base/browser/ui/scrollbar/scrollableElementOptions'; -import {ITerminalFont} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper'; +import {IShell, ITerminalFont} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper'; export class TerminalInstance { @@ -28,7 +28,7 @@ export class TerminalInstance { private font: ITerminalFont; public constructor( - private shell: string, + private shell: IShell, private parentDomElement: HTMLElement, private contextService: IWorkspaceContextService, private terminalService: ITerminalService, @@ -120,7 +120,10 @@ export class TerminalInstance { private createTerminalProcess(): cp.ChildProcess { let env = this.cloneEnv(); - env['PTYSHELL'] = this.shell; + env['PTYSHELL'] = this.shell.executable; + this.shell.args.forEach((arg, i) => { + env[`PTYSHELLARG${i}`] = arg; + }); env['PTYCWD'] = this.contextService.getWorkspace() ? this.contextService.getWorkspace().resource.fsPath : os.homedir(); return cp.fork('./terminalProcess', [], { env: env, diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalProcess.js b/src/vs/workbench/parts/terminal/electron-browser/terminalProcess.js index 3da56336061..f73ace07968 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalProcess.js +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalProcess.js @@ -8,7 +8,8 @@ var ptyJs = require('pty.js'); // The pty process needs to be run in its own child process to get around maxing out CPU on Mac, // see https://github.com/electron/electron/issues/38 -var ptyProcess = ptyJs.fork(process.env.PTYSHELL, [], { + +var ptyProcess = ptyJs.fork(process.env.PTYSHELL, getArgs(), { name: fs.existsSync('/usr/share/terminfo/x/xterm-256color') ? 'xterm-256color' : 'xterm', cwd: process.env.PTYCWD }); @@ -27,4 +28,14 @@ process.on('message', function (message) { } else if (message.event === 'resize') { ptyProcess.resize(message.cols, message.rows); } -}); \ No newline at end of file +}); + +function getArgs() { + var args = []; + var i = 0; + while (process.env['PTYSHELLARG' + i]) { + args.push(process.env['PTYSHELLARG' + i]); + i++; + } + return args; +} \ No newline at end of file -- GitLab