diff --git a/src/vs/platform/terminal/common/terminal.ts b/src/vs/platform/terminal/common/terminal.ts index 8c90aa61c62..3ff4e70ca4c 100644 --- a/src/vs/platform/terminal/common/terminal.ts +++ b/src/vs/platform/terminal/common/terminal.ts @@ -111,13 +111,23 @@ export const enum TerminalSettingId { ShellIntegrationCommandHistory = 'terminal.integrated.shellIntegration.history' } +export const enum PosixShellType { + PowerShell = 'pwsh', + Bash = 'bash', + Fish = 'fish', + Sh = 'sh', + Csh = 'csh', + Ksh = 'ksh', + Zsh = 'zsh', +} export const enum WindowsShellType { CommandPrompt = 'cmd', PowerShell = 'pwsh', Wsl = 'wsl', GitBash = 'gitbash' } -export type TerminalShellType = WindowsShellType | undefined; +export type TerminalShellType = PosixShellType | WindowsShellType | undefined; + export interface IRawTerminalInstanceLayoutInfo { relativeSize: number; terminal: T; diff --git a/src/vs/platform/terminal/node/terminalProcess.ts b/src/vs/platform/terminal/node/terminalProcess.ts index 2a1dfd1823f..23ab10777cb 100644 --- a/src/vs/platform/terminal/node/terminalProcess.ts +++ b/src/vs/platform/terminal/node/terminalProcess.ts @@ -17,7 +17,7 @@ import { URI } from 'vs/base/common/uri'; import { Promises } from 'vs/base/node/pfs'; import { localize } from 'vs/nls'; import { ILogService } from 'vs/platform/log/common/log'; -import { FlowControlConstants, IShellLaunchConfig, ITerminalChildProcess, ITerminalLaunchError, IProcessProperty, IProcessPropertyMap as IProcessPropertyMap, ProcessPropertyType, TerminalShellType, IProcessReadyEvent, ITerminalProcessOptions } from 'vs/platform/terminal/common/terminal'; +import { FlowControlConstants, IShellLaunchConfig, ITerminalChildProcess, ITerminalLaunchError, IProcessProperty, IProcessPropertyMap as IProcessPropertyMap, ProcessPropertyType, TerminalShellType, IProcessReadyEvent, ITerminalProcessOptions, PosixShellType } from 'vs/platform/terminal/common/terminal'; import { ChildProcessMonitor } from 'vs/platform/terminal/node/childProcessMonitor'; import { findExecutable, getShellIntegrationInjection, getWindowsBuildNumber, IShellIntegrationConfigInjection } from 'vs/platform/terminal/node/terminalEnvironment'; import { WindowsShellHelper } from 'vs/platform/terminal/node/windowsShellHelper'; @@ -75,6 +75,16 @@ interface IWriteObject { isBinary: boolean; } +const posixShellTypeMap = new Map([ + ['bash', PosixShellType.Bash], + ['csh', PosixShellType.Csh], + ['fish', PosixShellType.Fish], + ['ksh', PosixShellType.Ksh], + ['sh', PosixShellType.Sh], + ['pwsh', PosixShellType.PowerShell], + ['zsh', PosixShellType.Zsh] +]); + export class TerminalProcess extends Disposable implements ITerminalChildProcess { readonly id = 0; readonly shouldPersist = false; @@ -111,7 +121,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess get exitMessage(): string | undefined { return this._exitMessage; } get currentTitle(): string { return this._windowsShellHelper?.shellTitle || this._currentTitle; } - get shellType(): TerminalShellType { return this._windowsShellHelper ? this._windowsShellHelper.shellType : undefined; } + get shellType(): TerminalShellType { return isWindows ? this._windowsShellHelper?.shellType : posixShellTypeMap.get(this._currentTitle); } private readonly _onProcessData = this._register(new Emitter()); readonly onProcessData = this._onProcessData.event; @@ -389,6 +399,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess } this._currentTitle = ptyProcess.process; this._onDidChangeProperty.fire({ type: ProcessPropertyType.Title, value: this._currentTitle }); + this._onDidChangeProperty.fire({ type: ProcessPropertyType.ShellType, value: posixShellTypeMap.get(this.currentTitle) }); } shutdown(immediate: boolean): void {