diff --git a/package.json b/package.json index 4a5ba59325..51c25e6e5a 100644 --- a/package.json +++ b/package.json @@ -269,6 +269,24 @@ } }, "description": "Settings for VSCode Language Model API" + }, + "roo-cline.shell": { + "type": "object", + "properties": { + "osx": { + "type": "string", + "description": "Path to shell executable for macOS" + }, + "linux": { + "type": "string", + "description": "Path to shell executable for Linux" + }, + "windows": { + "type": "string", + "description": "Path to shell executable for Windows" + } + }, + "description": "Override default shell path for different operating systems" } } } diff --git a/src/integrations/terminal/TerminalRegistry.ts b/src/integrations/terminal/TerminalRegistry.ts index 2fb49e4825..7d9529721d 100644 --- a/src/integrations/terminal/TerminalRegistry.ts +++ b/src/integrations/terminal/TerminalRegistry.ts @@ -1,4 +1,5 @@ import * as vscode from "vscode" +import { TerminalProfile } from "../../utils/shell" export interface TerminalInfo { terminal: vscode.Terminal @@ -13,11 +14,24 @@ export class TerminalRegistry { private static terminals: TerminalInfo[] = [] private static nextTerminalId = 1 + private static getShellConfigKey(): string { + if (process.platform === "win32") { + return "windows" + } else if (process.platform === "darwin") { + return "osx" + } else { + return "linux" + } + } + static createTerminal(cwd?: string | vscode.Uri | undefined): TerminalInfo { + const shellConfig = this.getAutomationShellConfig() const terminal = vscode.window.createTerminal({ cwd, name: "Roo Code", iconPath: new vscode.ThemeIcon("rocket"), + shellPath: shellConfig?.path, + shellArgs: shellConfig?.args, env: { PAGER: "cat", }, @@ -61,4 +75,22 @@ export class TerminalRegistry { private static isTerminalClosed(terminal: vscode.Terminal): boolean { return terminal.exitStatus !== undefined } + + // Get the shell path from the extension settings, or use the default shell path. + private static getAutomationShell(): string | undefined { + const shellOverrides = vscode.workspace.getConfiguration("roo-cline.shell") || {} + return shellOverrides.get(this.getShellConfigKey()) + } + + // Get the shell path and args from the extension settings, or use the default shell path and args. + private static getAutomationShellConfig(): TerminalProfile | undefined { + const shell = this.getAutomationShell() + if (shell === undefined) { + return undefined + } + const shellProfiles = + vscode.workspace.getConfiguration(`terminal.integrated.profiles.${this.getShellConfigKey()}`) || {} + const selectedProfile = shellProfiles.get(shell) + return selectedProfile + } } diff --git a/src/utils/shell.ts b/src/utils/shell.ts index 2f7ffb3a88..ba9baeab3d 100644 --- a/src/utils/shell.ts +++ b/src/utils/shell.ts @@ -20,22 +20,22 @@ const SHELL_PATHS = { FALLBACK: "/bin/sh", } as const -interface MacTerminalProfile { +export interface TerminalProfile { path?: string + args?: string[] } +interface MacTerminalProfile extends TerminalProfile {} + type MacTerminalProfiles = Record -interface WindowsTerminalProfile { - path?: string +interface WindowsTerminalProfile extends TerminalProfile { source?: "PowerShell" | "WSL" } type WindowsTerminalProfiles = Record -interface LinuxTerminalProfile { - path?: string -} +interface LinuxTerminalProfile extends TerminalProfile {} type LinuxTerminalProfiles = Record