MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / getProfileShell

Method getProfileShell

src/integrations/terminal/Terminal.ts:512–588  ·  view source on GitHub ↗

* Resolves the configured VS Code terminal profile (see `terminalProfile` * setting / Terminal.getTerminalProfile) into a shell path and args by * reading VS Code's `terminal.integrated.profiles. ` configuration. * * This reuses VS Code's terminal profile concept so users ca

(
		platform: NodeJS.Platform = process.platform,
	)

Source from the content-addressed store, hash-verified

510 * configured or the profile cannot be resolved (default behavior).
511 */
512 public static getProfileShell(
513 platform: NodeJS.Platform = process.platform,
514 ): { shellPath: string; shellArgs?: string[]; env?: Record<string, string | null> } | undefined {
515 const profileName = Terminal.getTerminalProfile()
516
517 if (!profileName) {
518 return undefined
519 }
520
521 const platformKey = Terminal.getPlatformProfileKey(platform)
522
523 const profiles = Terminal.getConfiguredProfiles(platform)
524
525 const profile = profiles?.[profileName] as
526 | {
527 path?: string | string[]
528 args?: string | string[]
529 source?: string
530 env?: Record<string, unknown>
531 }
532 | null
533 | undefined
534
535 if (!profile) {
536 console.warn(`[Terminal] Configured terminal profile "${profileName}" not found for ${platformKey}.`)
537 return undefined
538 }
539
540 const pathValue = Terminal.resolveProfilePath(profile.path, platform)
541
542 if (!pathValue) {
543 // Profiles defined only by `source` (e.g. "PowerShell") can't be mapped to
544 // a shell path here, so we fall back to the default terminal.
545 console.warn(
546 `[Terminal] Terminal profile "${profileName}" has no resolvable "path"; using default terminal.`,
547 )
548 return undefined
549 }
550
551 const shellArgs = Array.isArray(profile.args)
552 ? profile.args.filter((arg): arg is string => typeof arg === "string")
553 : typeof profile.args === "string"
554 ? [profile.args]
555 : undefined
556
557 // VS Code profiles may declare their own `env` (e.g. to set a UTF-8 locale or
558 // a custom PATH). Preserve it so the inline terminal doesn't lose environment
559 // the user configured on the profile. A `null` value unsets that variable.
560 // Values come from user `settings.json`, so sanitize to string/null only.
561 let env: Record<string, string | null> | undefined
562
563 if (profile.env && typeof profile.env === "object") {
564 const sanitized: Record<string, string | null> = {}
565 const blockedKeys = new Set([
566 "ZDOTDIR",
567 "PROMPT_COMMAND",
568 "LD_PRELOAD",
569 "LD_LIBRARY_PATH",

Callers 5

constructorMethod · 0.80
isActiveShellCmdExeMethod · 0.80
isActiveShellFishMethod · 0.80

Calls 7

getPlatformProfileKeyMethod · 0.80
getConfiguredProfilesMethod · 0.80
resolveProfilePathMethod · 0.80
entriesMethod · 0.80
warnMethod · 0.65
hasMethod · 0.65
keysMethod · 0.65

Tested by

no test coverage detected