Skip to content

Commit 31bcb5a

Browse files
committed
Add terminal shell args setting
Fixes microsoft#7266
1 parent 5b0d712 commit 31bcb5a

5 files changed

Lines changed: 67 additions & 11 deletions

File tree

src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,40 @@ configurationRegistry.registerConfiguration({
2828
'type': 'string',
2929
'default': TERMINAL_DEFAULT_SHELL_LINUX
3030
},
31+
'terminal.integrated.shellArgs.linux': {
32+
'description': nls.localize('terminal.integrated.shellArgs.linux', "The command line arguments to use when on the Linux terminal."),
33+
'type': 'array',
34+
'items': {
35+
'type': 'string'
36+
},
37+
'default': []
38+
},
3139
'terminal.integrated.shell.osx': {
3240
'description': nls.localize('terminal.integrated.shell.osx', "The path of the shell that the terminal uses on OS X."),
3341
'type': 'string',
3442
'default': TERMINAL_DEFAULT_SHELL_OSX
3543
},
44+
'terminal.integrated.shellArgs.osx': {
45+
'description': nls.localize('terminal.integrated.shellArgs.osx', "The command line arguments to use when on the OS X terminal."),
46+
'type': 'array',
47+
'items': {
48+
'type': 'string'
49+
},
50+
'default': []
51+
},
3652
'terminal.integrated.shell.windows': {
3753
'description': nls.localize('terminal.integrated.shell.windows', "The path of the shell that the terminal uses on Windows."),
3854
'type': 'string',
3955
'default': TERMINAL_DEFAULT_SHELL_WINDOWS
4056
},
57+
'terminal.integrated.shellArgs.windows': {
58+
'description': nls.localize('terminal.integrated.shellArgs.windows', "The command line arguments to use when on the Windows terminal."),
59+
'type': 'array',
60+
'items': {
61+
'type': 'string'
62+
},
63+
'default': []
64+
},
4165
'terminal.integrated.fontFamily': {
4266
'description': nls.localize('terminal.integrated.fontFamily', "Controls the font family of the terminal, this defaults to editor.fontFamily's value."),
4367
'type': 'string'

src/vs/workbench/parts/terminal/electron-browser/terminal.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export interface ITerminalConfiguration {
2727
osx: string,
2828
windows: string
2929
},
30+
shellArgs: {
31+
linux: string[],
32+
osx: string[],
33+
windows: string[]
34+
},
3035
fontFamily: string,
3136
fontSize: number,
3237
lineHeight: number

src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ export interface ITerminalFont {
7676
charHeight: number;
7777
}
7878

79+
export interface IShell {
80+
executable: string;
81+
args: string[];
82+
}
83+
7984
/**
8085
* Encapsulates terminal configuration logic, the primary purpose of this file is so that platform
8186
* specific test cases can be written.
@@ -137,15 +142,23 @@ export class TerminalConfigHelper {
137142
return this.measureFont(fontFamily, fontSize, lineHeight);
138143
}
139144

140-
public getShell(): string {
145+
public getShell(): IShell {
141146
let config = this.configurationService.getConfiguration<ITerminalConfiguration>();
147+
let shell: IShell = {
148+
executable: '',
149+
args: []
150+
};
142151
if (this.platform === Platform.Windows) {
143-
return config.terminal.integrated.shell.windows;
144-
}
145-
if (this.platform === Platform.Mac) {
146-
return config.terminal.integrated.shell.osx;
152+
shell.executable = config.terminal.integrated.shell.windows;
153+
shell.args = config.terminal.integrated.shellArgs.windows;
154+
} else if (this.platform === Platform.Mac) {
155+
shell.executable = config.terminal.integrated.shell.osx;
156+
shell.args = config.terminal.integrated.shellArgs.osx;
157+
} else if (this.platform === Platform.Linux) {
158+
shell.executable = config.terminal.integrated.shell.linux;
159+
shell.args = config.terminal.integrated.shellArgs.linux;
147160
}
148-
return config.terminal.integrated.shell.linux;
161+
return shell;
149162
}
150163

151164
private toInteger(source: any, minimum?: number): number {

src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
1717
import {ITerminalService} from 'vs/workbench/parts/terminal/electron-browser/terminal';
1818
import {DomScrollableElement} from 'vs/base/browser/ui/scrollbar/scrollableElement';
1919
import {ScrollbarVisibility} from 'vs/base/browser/ui/scrollbar/scrollableElementOptions';
20-
import {ITerminalFont} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
20+
import {IShell, ITerminalFont} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
2121

2222
export class TerminalInstance {
2323

@@ -28,7 +28,7 @@ export class TerminalInstance {
2828
private font: ITerminalFont;
2929

3030
public constructor(
31-
private shell: string,
31+
private shell: IShell,
3232
private parentDomElement: HTMLElement,
3333
private contextService: IWorkspaceContextService,
3434
private terminalService: ITerminalService,
@@ -120,7 +120,10 @@ export class TerminalInstance {
120120

121121
private createTerminalProcess(): cp.ChildProcess {
122122
let env = this.cloneEnv();
123-
env['PTYSHELL'] = this.shell;
123+
env['PTYSHELL'] = this.shell.executable;
124+
this.shell.args.forEach((arg, i) => {
125+
env[`PTYSHELLARG${i}`] = arg;
126+
});
124127
env['PTYCWD'] = this.contextService.getWorkspace() ? this.contextService.getWorkspace().resource.fsPath : os.homedir();
125128
return cp.fork('./terminalProcess', [], {
126129
env: env,

src/vs/workbench/parts/terminal/electron-browser/terminalProcess.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ var ptyJs = require('pty.js');
88

99
// The pty process needs to be run in its own child process to get around maxing out CPU on Mac,
1010
// see https://github.com/electron/electron/issues/38
11-
var ptyProcess = ptyJs.fork(process.env.PTYSHELL, [], {
11+
12+
var ptyProcess = ptyJs.fork(process.env.PTYSHELL, getArgs(), {
1213
name: fs.existsSync('/usr/share/terminfo/x/xterm-256color') ? 'xterm-256color' : 'xterm',
1314
cwd: process.env.PTYCWD
1415
});
@@ -27,4 +28,14 @@ process.on('message', function (message) {
2728
} else if (message.event === 'resize') {
2829
ptyProcess.resize(message.cols, message.rows);
2930
}
30-
});
31+
});
32+
33+
function getArgs() {
34+
var args = [];
35+
var i = 0;
36+
while (process.env['PTYSHELLARG' + i]) {
37+
args.push(process.env['PTYSHELLARG' + i]);
38+
i++;
39+
}
40+
return args;
41+
}

0 commit comments

Comments
 (0)