src/vs/platform/terminal/common/terminalPlatformConfiguration.ts

481 LOC · 479 covered · 2 uncovered · 2 ranges · 1 concepts · 1 introducers · 1 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- ptyHostService.ts ×54
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { Codicon, getAllCodicons } from '../../../base/common/codicons.js';
7 > import { IJSONSchema, IJSONSchemaMap } from '../../../base/common/jsonSchema.js';
8 > import { OperatingSystem, Platform, PlatformToString } from '../../../base/common/platform.js';
9 > import { localize } from '../../../nls.js';
10 > import { ConfigurationScope, Extensions, IConfigurationNode, IConfigurationRegistry } from '../../configuration/common/configurationRegistry.js';
11 > import { Registry } from '../../registry/common/platform.js';
12 > import { IExtensionTerminalProfile, ITerminalProfile, TerminalSettingId } from './terminal.js';
13 > import { createProfileSchemaEnums } from './terminalProfiles.js';
14 >
15 > export const terminalColorSchema: IJSONSchema = {
16 > type: ['string', 'null'],
17 > enum: [
18 > 'terminal.ansiBlack',
19 > 'terminal.ansiRed',
20 > 'terminal.ansiGreen',
21 > 'terminal.ansiYellow',
22 > 'terminal.ansiBlue',
23 > 'terminal.ansiMagenta',
24 > 'terminal.ansiCyan',
25 > 'terminal.ansiWhite'
26 > ],
27 > default: null
28 > };
29 >
30 > export const terminalIconSchema: IJSONSchema = {
31 > type: 'string',
32 > enum: Array.from(getAllCodicons(), icon => icon.id),
33 > markdownEnumDescriptions: Array.from(getAllCodicons(), icon => `$(${icon.id})`),
34 > };
35 >
36 > export const terminalProfileBaseProperties: IJSONSchemaMap = {
37 > args: {
38 > description: localize('terminalProfile.args', 'An optional set of arguments to run the shell executable with.'),
39 > type: 'array',
40 > items: {
41 > type: 'string'
42 > }
43 > },
44 > icon: {
45 > description: localize('terminalProfile.icon', 'A codicon ID to associate with the terminal icon.'),
46 > ...terminalIconSchema
47 > },
48 > color: {
49 > description: localize('terminalProfile.color', 'A theme color ID to associate with the terminal icon.'),
50 > ...terminalColorSchema
51 > },
52 > env: {
53 > 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."),
54 > type: 'object',
55 > additionalProperties: {
56 > type: ['string', 'null']
57 > },
58 > default: {}
59 > }
60 > };
61 >
62 > const terminalProfileSchema: IJSONSchema = {
63 > type: 'object',
64 > required: ['path'],
65 > properties: {
66 > path: {
67 > description: localize('terminalProfile.path', 'A single path to a shell executable or an array of paths that will be used as fallbacks when one fails.'),
68 > type: ['string', 'array'],
69 > items: {
70 > type: 'string'
71 > }
72 > },
73 > overrideName: {
74 > description: localize('terminalProfile.overrideName', 'Whether or not to replace the dynamic terminal title that detects what program is running with the static profile name.'),
75 > type: 'boolean'
76 > },
77 > ...terminalProfileBaseProperties
78 > }
79 > };
80 >
81 > const terminalAutomationProfileSchema: IJSONSchema = {
82 > type: 'object',
83 > required: ['path'],
84 > properties: {
85 > path: {
86 > description: localize('terminalAutomationProfile.path', 'A path to a shell executable.'),
87 > type: ['string'],
88 > items: {
89 > type: 'string'
90 > }
91 > },
92 > ...terminalProfileBaseProperties
93 > }
94 > };
95 >
96 > function createTerminalProfileMarkdownDescription(platform: Platform.Linux | Platform.Mac | Platform.Windows): string {
97 > const key = platform === Platform.Linux ? 'linux' : platform === Platform.Mac ? 'osx' : 'windows';
98 > return localize(
99 > {
100 > key: 'terminal.integrated.profile',
101 > comment: ['{0} is the platform, {1} is a code block, {2} and {3} are a link start and end']
102 > },
103 > "A set of terminal profile customizations for {0} which allows adding, removing or changing how terminals are launched. Profiles are made up of a mandatory path, optional arguments and other presentation options.\n\nTo override an existing profile use its profile name as the key, for example:\n\n{1}\n\n{2}Read more about configuring profiles{3}.",
104 > PlatformToString(platform),
105 > '```json\n"terminal.integrated.profile.' + key + '": {\n "bash": null\n}\n```',
106 > '[',
107 > '](https://code.visualstudio.com/docs/terminal/profiles)'
108 > );
109 > }
110 >
111 > const terminalPlatformConfiguration: IConfigurationNode = {
112 > id: 'terminal',
113 > order: 100,
114 > title: localize('terminalIntegratedConfigurationTitle', "Integrated Terminal"),
115 > type: 'object',
116 > properties: {
117 > [TerminalSettingId.AutomationProfileLinux]: {
118 > restricted: true,
119 > markdownDescription: localize('terminal.integrated.automationProfile.linux', "The terminal profile to use on Linux for automation-related terminal usage like tasks and debug."),
120 > type: ['object', 'null'],
121 > default: null,
122 > 'anyOf': [
123 > { type: 'null' },
124 > terminalAutomationProfileSchema
125 > ],
126 > defaultSnippets: [
127 > {
128 > body: {
129 > path: '${1}',
130 > icon: '${2}'
131 > }
132 > }
133 > ]
134 > },
135 > [TerminalSettingId.AutomationProfileMacOs]: {
136 > restricted: true,
137 > markdownDescription: localize('terminal.integrated.automationProfile.osx', "The terminal profile to use on macOS for automation-related terminal usage like tasks and debug."),
138 > type: ['object', 'null'],
139 > default: null,
140 > 'anyOf': [
141 > { type: 'null' },
142 > terminalAutomationProfileSchema
143 > ],
144 > defaultSnippets: [
145 > {
146 > body: {
147 > path: '${1}',
148 > icon: '${2}'
149 > }
150 > }
151 > ]
152 > },
153 > [TerminalSettingId.AutomationProfileWindows]: {
154 > restricted: true,
155 > markdownDescription: localize('terminal.integrated.automationProfile.windows', "The terminal profile to use for automation-related terminal usage like tasks and debug. This setting will currently be ignored if {0} (now deprecated) is set.", '`terminal.integrated.automationShell.windows`'),
156 > type: ['object', 'null'],
157 > default: null,
158 > 'anyOf': [
159 > { type: 'null' },
160 > terminalAutomationProfileSchema
161 > ],
162 > defaultSnippets: [
163 > {
164 > body: {
165 > path: '${1}',
166 > icon: '${2}'
167 > }
168 > }
169 > ]
170 > },
171 > [TerminalSettingId.AgentHostProfileLinux]: {
172 > restricted: true,
173 > markdownDescription: localize('terminal.integrated.agentHostProfile.linux', "The terminal profile to use on Linux for agent host terminals, including shells launched by AI agent tools. Accepts either a profile name from {0} or an inline profile object. When unset, falls back to {1}. Currently applies to the local agent host. Only the executable `path` is honored today; `args` and `env` from the profile are ignored. Remote agent hosts need remote-side shell configuration because local resolved paths may be invalid on the remote.", '`#terminal.integrated.profiles.linux#`', '`#terminal.integrated.defaultProfile.linux#`'),
174 > type: ['string', 'object', 'null'],
175 > default: null,
176 > 'anyOf': [
177 > { type: 'null' },
178 > { type: 'string' },
179 > terminalAutomationProfileSchema
180 > ],
181 > defaultSnippets: [
182 > {
183 > body: {
184 > path: '${1}',
185 > icon: '${2}'
186 > }
187 > }
188 > ]
189 > },
190 > [TerminalSettingId.AgentHostProfileMacOs]: {
191 > restricted: true,
192 > markdownDescription: localize('terminal.integrated.agentHostProfile.osx', "The terminal profile to use on macOS for agent host terminals, including shells launched by AI agent tools. Accepts either a profile name from {0} or an inline profile object. When unset, falls back to {1}. Currently applies to the local agent host. Only the executable `path` is honored today; `args` and `env` from the profile are ignored. Remote agent hosts need remote-side shell configuration because local resolved paths may be invalid on the remote.", '`#terminal.integrated.profiles.osx#`', '`#terminal.integrated.defaultProfile.osx#`'),
193 > type: ['string', 'object', 'null'],
194 > default: null,
195 > 'anyOf': [
196 > { type: 'null' },
197 > { type: 'string' },
198 > terminalAutomationProfileSchema
199 > ],
200 > defaultSnippets: [
201 > {
202 > body: {
203 > path: '${1}',
204 > icon: '${2}'
205 > }
206 > }
207 > ]
208 > },
209 > [TerminalSettingId.AgentHostProfileWindows]: {
210 > restricted: true,
211 > markdownDescription: localize('terminal.integrated.agentHostProfile.windows', "The terminal profile to use on Windows for agent host terminals, including shells launched by AI agent tools. Accepts either a profile name from {0} or an inline profile object. When unset, falls back to {1}. Currently applies to the local agent host. Only the executable `path` is honored today; `args` and `env` from the profile are ignored. Remote agent hosts need remote-side shell configuration because local resolved paths may be invalid on the remote.", '`#terminal.integrated.profiles.windows#`', '`#terminal.integrated.defaultProfile.windows#`'),
212 > type: ['string', 'object', 'null'],
213 > default: null,
214 > 'anyOf': [
215 > { type: 'null' },
216 > { type: 'string' },
217 > terminalAutomationProfileSchema
218 > ],
219 > defaultSnippets: [
220 > {
221 > body: {
222 > path: '${1}',
223 > icon: '${2}'
224 > }
225 > }
226 > ]
227 > },
228 > [TerminalSettingId.ProfilesWindows]: {
229 > restricted: true,
230 > markdownDescription: createTerminalProfileMarkdownDescription(Platform.Windows),
231 > type: 'object',
232 > default: {
233 > 'PowerShell': {
234 > source: 'PowerShell',
235 > icon: Codicon.terminalPowershell.id,
236 > },
237 > 'Command Prompt': {
238 > path: [
239 > '${env:windir}\\Sysnative\\cmd.exe',
240 > '${env:windir}\\System32\\cmd.exe'
241 > ],
242 > args: [],
243 > icon: Codicon.terminalCmd.id,
244 > },
245 > 'Git Bash': {
246 > source: 'Git Bash',
247 > icon: Codicon.terminalGitBash.id,
248 > }
249 > },
250 > additionalProperties: {
251 > 'anyOf': [
252 > {
253 > type: 'object',
254 > required: ['source'],
255 > properties: {
256 > source: {
257 > description: localize('terminalProfile.windowsSource', 'A profile source that will auto detect the paths to the shell. Note that non-standard executable locations are not supported and must be created manually in a new profile.'),
258 > enum: ['PowerShell', 'Git Bash']
259 > },
260 > ...terminalProfileBaseProperties
261 > }
262 > },
263 > {
264 > type: 'object',
265 > required: ['extensionIdentifier', 'id', 'title'],
266 > properties: {
267 > extensionIdentifier: {
268 > description: localize('terminalProfile.windowsExtensionIdentifier', 'The extension that contributed this profile.'),
269 > type: 'string'
270 > },
271 > id: {
272 > description: localize('terminalProfile.windowsExtensionId', 'The id of the extension terminal'),
273 > type: 'string'
274 > },
275 > title: {
276 > description: localize('terminalProfile.windowsExtensionTitle', 'The name of the extension terminal'),
277 > type: 'string'
278 > },
279 > ...terminalProfileBaseProperties
280 > }
281 > },
282 > { type: 'null' },
283 > terminalProfileSchema
284 > ]
285 > }
286 > },
287 > [TerminalSettingId.ProfilesMacOs]: {
288 > restricted: true,
289 > markdownDescription: createTerminalProfileMarkdownDescription(Platform.Mac),
290 > type: 'object',
291 > default: {
292 > 'bash': {
293 > path: 'bash',
294 > args: ['-l'],
295 > icon: Codicon.terminalBash.id
296 > },
297 > 'zsh': {
298 > path: 'zsh',
299 > args: ['-l']
300 > },
301 > 'fish': {
302 > path: 'fish',
303 > args: ['-l']
304 > },
305 > 'tmux': {
306 > path: 'tmux',
307 > icon: Codicon.terminalTmux.id
308 > },
309 > 'pwsh': {
310 > path: 'pwsh',
311 > icon: Codicon.terminalPowershell.id
312 > }
313 > },
314 > additionalProperties: {
315 > 'anyOf': [
316 > {
317 > type: 'object',
318 > required: ['extensionIdentifier', 'id', 'title'],
319 > properties: {
320 > extensionIdentifier: {
321 > description: localize('terminalProfile.osxExtensionIdentifier', 'The extension that contributed this profile.'),
322 > type: 'string'
323 > },
324 > id: {
325 > description: localize('terminalProfile.osxExtensionId', 'The id of the extension terminal'),
326 > type: 'string'
327 > },
328 > title: {
329 > description: localize('terminalProfile.osxExtensionTitle', 'The name of the extension terminal'),
330 > type: 'string'
331 > },
332 > ...terminalProfileBaseProperties
333 > }
334 > },
335 > { type: 'null' },
336 > terminalProfileSchema
337 > ]
338 > }
339 > },
340 > [TerminalSettingId.ProfilesLinux]: {
341 > restricted: true,
342 > markdownDescription: createTerminalProfileMarkdownDescription(Platform.Linux),
343 > type: 'object',
344 > default: {
345 > 'bash': {
346 > path: 'bash',
347 > icon: Codicon.terminalBash.id
348 > },
349 > 'zsh': {
350 > path: 'zsh'
351 > },
352 > 'fish': {
353 > path: 'fish'
354 > },
355 > 'tmux': {
356 > path: 'tmux',
357 > icon: Codicon.terminalTmux.id
358 > },
359 > 'pwsh': {
360 > path: 'pwsh',
361 > icon: Codicon.terminalPowershell.id
362 > }
363 > },
364 > additionalProperties: {
365 > 'anyOf': [
366 > {
367 > type: 'object',
368 > required: ['extensionIdentifier', 'id', 'title'],
369 > properties: {
370 > extensionIdentifier: {
371 > description: localize('terminalProfile.linuxExtensionIdentifier', 'The extension that contributed this profile.'),
372 > type: 'string'
373 > },
374 > id: {
375 > description: localize('terminalProfile.linuxExtensionId', 'The id of the extension terminal'),
376 > type: 'string'
377 > },
378 > title: {
379 > description: localize('terminalProfile.linuxExtensionTitle', 'The name of the extension terminal'),
380 > type: 'string'
381 > },
382 > ...terminalProfileBaseProperties
383 > }
384 > },
385 > { type: 'null' },
386 > terminalProfileSchema
387 > ]
388 > }
389 > },
390 > [TerminalSettingId.UseWslProfiles]: {
391 > description: localize('terminal.integrated.useWslProfiles', 'Controls whether or not WSL distros are shown in the terminal dropdown'),
392 > type: 'boolean',
393 > default: true
394 > },
395 > [TerminalSettingId.InheritEnv]: {
396 > scope: ConfigurationScope.APPLICATION,
397 > description: localize('terminal.integrated.inheritEnv', "Whether new shells should inherit their environment from VS Code, which may source a login shell to ensure $PATH and other development variables are initialized. This has no effect on Windows."),
398 > type: 'boolean',
399 > default: true
400 > },
401 > [TerminalSettingId.PersistentSessionScrollback]: {
402 > scope: ConfigurationScope.APPLICATION,
403 > markdownDescription: localize('terminal.integrated.persistentSessionScrollback', "Controls the maximum amount of lines that will be restored when reconnecting to a persistent terminal session. Increasing this will restore more lines of scrollback at the cost of more memory and increase the time it takes to connect to terminals on start up. This setting requires a restart to take effect and should be set to a value less than or equal to `#terminal.integrated.scrollback#`."),
404 > type: 'number',
405 > default: 100
406 > },
407 > [TerminalSettingId.ShowLinkHover]: {
408 > scope: ConfigurationScope.APPLICATION,
409 > description: localize('terminal.integrated.showLinkHover', "Whether to show hovers for links in the terminal output."),
410 > type: 'boolean',
411 > default: true
412 > },
413 > [TerminalSettingId.IgnoreProcessNames]: {
414 > markdownDescription: localize('terminal.integrated.confirmIgnoreProcesses', "A set of process names to ignore when using the {0} setting.", '`#terminal.integrated.confirmOnKill#`'),
415 > type: 'array',
416 > items: {
417 > type: 'string',
418 > uniqueItems: true
419 > },
420 > default: [
421 > // Popular prompt programs, these should not count as child processes
422 > 'starship',
423 > 'oh-my-posh',
424 > // Git bash may runs a subprocess of itself (bin\bash.exe -> usr\bin\bash.exe)
425 > 'bash',
426 > 'zsh',
427 > ]
428 > }
429 > }
430 > };
431 >
432 > /**
433 > * Registers terminal configurations required by shared process and remote server.
434 > */
435 > export function registerTerminalPlatformConfiguration() {
436 > Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration(terminalPlatformConfiguration);
437 > registerTerminalDefaultProfileConfiguration();
438 > }
439 >
440 > let defaultProfilesConfiguration: IConfigurationNode | undefined;
441 > export function registerTerminalDefaultProfileConfiguration(detectedProfiles?: { os: OperatingSystem; profiles: ITerminalProfile[] }, extensionContributedProfiles?: readonly IExtensionTerminalProfile[]) {
442 > const registry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
443 > let profileEnum;
444 > if (detectedProfiles) {
445 profileEnum = createProfileSchemaEnums(detectedProfiles?.profiles, extensionContributedProfiles);
446 }
447 > const oldDefaultProfilesConfiguration = defaultProfilesConfiguration; ptyHostService.ts ×54
448 > defaultProfilesConfiguration = {
449 > id: 'terminal',
450 > order: 100,
451 > title: localize('terminalIntegratedConfigurationTitle', "Integrated Terminal"),
452 > type: 'object',
453 > properties: {
454 > [TerminalSettingId.DefaultProfileLinux]: {
455 > restricted: true,
456 > markdownDescription: localize('terminal.integrated.defaultProfile.linux', "The default terminal profile on Linux."),
457 > type: ['string', 'null'],
458 > default: null,
459 > enum: detectedProfiles?.os === OperatingSystem.Linux ? profileEnum?.values : undefined,
460 > markdownEnumDescriptions: detectedProfiles?.os === OperatingSystem.Linux ? profileEnum?.markdownDescriptions : undefined
461 > },
462 > [TerminalSettingId.DefaultProfileMacOs]: {
463 > restricted: true,
464 > markdownDescription: localize('terminal.integrated.defaultProfile.osx', "The default terminal profile on macOS."),
465 > type: ['string', 'null'],
466 > default: null,
467 > enum: detectedProfiles?.os === OperatingSystem.Macintosh ? profileEnum?.values : undefined,
468 > markdownEnumDescriptions: detectedProfiles?.os === OperatingSystem.Macintosh ? profileEnum?.markdownDescriptions : undefined
469 > },
470 > [TerminalSettingId.DefaultProfileWindows]: {
471 > restricted: true,
472 > markdownDescription: localize('terminal.integrated.defaultProfile.windows', "The default terminal profile on Windows."),
473 > type: ['string', 'null'],
474 > default: null,
475 > enum: detectedProfiles?.os === OperatingSystem.Windows ? profileEnum?.values : undefined,
476 > markdownEnumDescriptions: detectedProfiles?.os === OperatingSystem.Windows ? profileEnum?.markdownDescriptions : undefined
477 > },
478 > }
479 > };
480 > registry.updateConfigurations({ add: [defaultProfilesConfiguration], remove: oldDefaultProfilesConfiguration ? [oldDefaultProfilesConfiguration] : [] });
481 > }