diff --git a/src/vs/platform/terminal/common/terminal.ts b/src/vs/platform/terminal/common/terminal.ts index 82b064a99af2b..2c4fe17d207b4 100644 --- a/src/vs/platform/terminal/common/terminal.ts +++ b/src/vs/platform/terminal/common/terminal.ts @@ -560,6 +560,7 @@ export interface ITerminalProfile { args?: string | string[] | undefined; env?: ITerminalEnvironment; overrideName?: boolean; + color?: string; icon?: ThemeIcon | URI | { light: URI, dark: URI }; } @@ -582,6 +583,7 @@ export interface IBaseUnresolvedTerminalProfile { isAutoDetected?: boolean; overrideName?: boolean; icon?: ThemeIcon | URI | { light: URI, dark: URI }; + color?: string; env?: ITerminalEnvironment; } diff --git a/src/vs/platform/terminal/common/terminalPlatformConfiguration.ts b/src/vs/platform/terminal/common/terminalPlatformConfiguration.ts index d250bb88d6a3a..a168666190501 100644 --- a/src/vs/platform/terminal/common/terminalPlatformConfiguration.ts +++ b/src/vs/platform/terminal/common/terminalPlatformConfiguration.ts @@ -39,6 +39,10 @@ const terminalProfileSchema: IJSONSchema = { enum: Array.from(iconRegistry.all, icon => icon.id), markdownEnumDescriptions: Array.from(iconRegistry.all, icon => `$(${icon.id})`), }, + color: { + description: localize('terminalProfile.color', 'A theme color ID to associate with this terminal.'), + type: 'string' + }, env: { markdownDescription: localize('terminalProfile.env', "An object with environment variables that will be added to the terminal profile process. Set to `null` to delete environment variables from the base environment."), type: 'object', @@ -204,6 +208,10 @@ const terminalPlatformConfiguration: IConfigurationNode = { enum: Array.from(iconRegistry.all, icon => icon.id), markdownEnumDescriptions: Array.from(iconRegistry.all, icon => `$(${icon.id})`), }, + color: { + description: localize('terminalProfile.color', 'A theme color ID to associate with this terminal.'), + type: 'string' + }, env: { markdownDescription: localize('terminalProfile.env', "An object with environment variables that will be added to the terminal profile process. Set to `null` to delete environment variables from the base environment."), type: 'object', @@ -385,6 +393,9 @@ function createProfileDescription(profile: ITerminalProfile): string { if (profile.overrideName !== undefined) { description += `\n- overrideName: ${profile.overrideName}`; } + if (profile.color) { + description += `\n- color: ${profile.color}`; + } if (profile.env) { description += `\n- env: ${JSON.stringify(profile.env)}`; } diff --git a/src/vs/platform/terminal/node/terminalProfiles.ts b/src/vs/platform/terminal/node/terminalProfiles.ts index e546d244defb7..8082d39f17fdf 100644 --- a/src/vs/platform/terminal/node/terminalProfiles.ts +++ b/src/vs/platform/terminal/node/terminalProfiles.ts @@ -166,6 +166,7 @@ async function transformToTerminalProfiles( if (validatedProfile) { validatedProfile.isAutoDetected = profile.isAutoDetected; validatedProfile.icon = icon; + validatedProfile.color = profile.color; resultProfiles.push(validatedProfile); } else { logService?.trace('profile not validated', profileName, originalPaths); diff --git a/src/vs/workbench/contrib/terminal/browser/terminalIcon.ts b/src/vs/workbench/contrib/terminal/browser/terminalIcon.ts index b4b18a7b9bd6b..96747da86e499 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalIcon.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalIcon.ts @@ -14,9 +14,9 @@ import { ITerminalInstance } from 'vs/workbench/contrib/terminal/browser/termina export function getColorClass(terminal: ITerminalInstance): string | undefined { let color = undefined; if (terminal.color) { - color = terminal.color; + color = terminal.color.replace(/\./g, '_'); } else if (ThemeIcon.isThemeIcon(terminal.icon) && terminal.icon.color) { - color = terminal.icon.color.id.replace('.', '_'); + color = terminal.icon.color.id.replace(/\./g, '_'); } if (color) { return `terminal-icon-${color}`; diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index f715d7b202924..5cbde2e9fb15a 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -336,6 +336,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { } private _getColor(): string | undefined { + console.log('_getColor', this.shellLaunchConfig.color); if (this.shellLaunchConfig.color) { return this.shellLaunchConfig.color; } @@ -1821,7 +1822,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { const items: IQuickPickItem[] = []; for (const color of colors) { items.push({ - label: `$(${Codicon.circleFilled.id}) ${color.replace('terminal.ansi', '')}`, id: `${color.replace(/\./g, '_')}`, description: `${color}`, iconClasses: [`terminal-icon-${color.replace(/\./g, '_')}`] + label: `$(${Codicon.circleFilled.id}) ${color.replace('terminal.ansi', '')}`, id: color, description: color, iconClasses: [`terminal-icon-${color.replace(/\./g, '_')}`] }); } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.ts b/src/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.ts index 71a5445705e3d..9ce81ae6e03ed 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.ts @@ -113,11 +113,15 @@ export abstract class BaseTerminalProfileResolverService implements ITerminalPro // Verify the icon is valid, and fallback correctly to the generic terminal id if there is // an issue shellLaunchConfig.icon = this._getCustomIcon(shellLaunchConfig.icon) || this._getCustomIcon(resolvedProfile.icon) || Codicon.terminal; + // Override the name if specified if (resolvedProfile.overrideName) { shellLaunchConfig.name = resolvedProfile.profileName; } + // TODO: Verify + shellLaunchConfig.color = resolvedProfile.color; + // Resolve useShellEnvironment based on the setting if it's not set if (shellLaunchConfig.useShellEnvironment === undefined) { shellLaunchConfig.useShellEnvironment = this._configurationService.getValue(TerminalSettingId.InheritEnv); diff --git a/src/vs/workbench/contrib/terminal/browser/terminalService.ts b/src/vs/workbench/contrib/terminal/browser/terminalService.ts index 0ddf5c179d8fb..fe3f67b945f71 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalService.ts @@ -1007,6 +1007,7 @@ export class TerminalService implements ITerminalService { args: profile.args, env: profile.env, icon: profile.icon, + color: profile.color, name: profile.overrideName ? profile.profileName : undefined, cwd };