Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
32 changes: 32 additions & 0 deletions src/integrations/terminal/TerminalRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as vscode from "vscode"
import { TerminalProfile } from "../../utils/shell"

export interface TerminalInfo {
terminal: vscode.Terminal
Expand All @@ -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",
},
Expand Down Expand Up @@ -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<string>(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<TerminalProfile>(shell)
return selectedProfile
}
}
12 changes: 6 additions & 6 deletions src/utils/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, MacTerminalProfile>

interface WindowsTerminalProfile {
path?: string
interface WindowsTerminalProfile extends TerminalProfile {
source?: "PowerShell" | "WSL"
}

type WindowsTerminalProfiles = Record<string, WindowsTerminalProfile>

interface LinuxTerminalProfile {
path?: string
}
interface LinuxTerminalProfile extends TerminalProfile {}

type LinuxTerminalProfiles = Record<string, LinuxTerminalProfile>

Expand Down
Loading