Skip to content

Commit 06f1e81

Browse files
committed
Add shell override configuration
Fixes macOS zsh prompt parsing issue (#237) by setting the shell override to bash for the terminal integration.
1 parent 1c9dcad commit 06f1e81

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,24 @@
269269
}
270270
},
271271
"description": "Settings for VSCode Language Model API"
272+
},
273+
"roo-cline.shell": {
274+
"type": "object",
275+
"properties": {
276+
"osx": {
277+
"type": "string",
278+
"description": "Path to shell executable for macOS"
279+
},
280+
"linux": {
281+
"type": "string",
282+
"description": "Path to shell executable for Linux"
283+
},
284+
"windows": {
285+
"type": "string",
286+
"description": "Path to shell executable for Windows"
287+
}
288+
},
289+
"description": "Override default shell path for different operating systems"
272290
}
273291
}
274292
}

src/integrations/terminal/TerminalRegistry.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as vscode from "vscode"
2+
import { TerminalProfile } from "../../utils/shell"
23

34
export interface TerminalInfo {
45
terminal: vscode.Terminal
@@ -13,11 +14,24 @@ export class TerminalRegistry {
1314
private static terminals: TerminalInfo[] = []
1415
private static nextTerminalId = 1
1516

17+
private static getShellConfigKey(): string {
18+
if (process.platform === "win32") {
19+
return "windows"
20+
} else if (process.platform === "darwin") {
21+
return "osx"
22+
} else {
23+
return "linux"
24+
}
25+
}
26+
1627
static createTerminal(cwd?: string | vscode.Uri | undefined): TerminalInfo {
28+
const shellConfig = this.getAutomationShellConfig()
1729
const terminal = vscode.window.createTerminal({
1830
cwd,
1931
name: "Roo Code",
2032
iconPath: new vscode.ThemeIcon("rocket"),
33+
shellPath: shellConfig?.path,
34+
shellArgs: shellConfig?.args,
2135
env: {
2236
PAGER: "cat",
2337
},
@@ -61,4 +75,22 @@ export class TerminalRegistry {
6175
private static isTerminalClosed(terminal: vscode.Terminal): boolean {
6276
return terminal.exitStatus !== undefined
6377
}
78+
79+
// Get the shell path from the extension settings, or use the default shell path.
80+
private static getAutomationShell(): string | undefined {
81+
const shellOverrides = vscode.workspace.getConfiguration("roo-cline.shell") || {}
82+
return shellOverrides.get<string>(this.getShellConfigKey())
83+
}
84+
85+
// Get the shell path and args from the extension settings, or use the default shell path and args.
86+
private static getAutomationShellConfig(): TerminalProfile | undefined {
87+
const shell = this.getAutomationShell()
88+
if (shell === undefined) {
89+
return undefined
90+
}
91+
const shellProfiles =
92+
vscode.workspace.getConfiguration(`terminal.integrated.profiles.${this.getShellConfigKey()}`) || {}
93+
const selectedProfile = shellProfiles.get<TerminalProfile>(shell)
94+
return selectedProfile
95+
}
6496
}

src/utils/shell.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ const SHELL_PATHS = {
2020
FALLBACK: "/bin/sh",
2121
} as const
2222

23-
interface MacTerminalProfile {
23+
export interface TerminalProfile {
2424
path?: string
25+
args?: string[]
2526
}
2627

28+
interface MacTerminalProfile extends TerminalProfile {}
29+
2730
type MacTerminalProfiles = Record<string, MacTerminalProfile>
2831

29-
interface WindowsTerminalProfile {
30-
path?: string
32+
interface WindowsTerminalProfile extends TerminalProfile {
3133
source?: "PowerShell" | "WSL"
3234
}
3335

3436
type WindowsTerminalProfiles = Record<string, WindowsTerminalProfile>
3537

36-
interface LinuxTerminalProfile {
37-
path?: string
38-
}
38+
interface LinuxTerminalProfile extends TerminalProfile {}
3939

4040
type LinuxTerminalProfiles = Record<string, LinuxTerminalProfile>
4141

0 commit comments

Comments
 (0)