mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
Merge pull request #144624 from microsoft/tyriar/posix_shell_type
Support shell type context key on mac/linux
This commit is contained in:
@@ -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<T> {
|
||||
relativeSize: number;
|
||||
terminal: T;
|
||||
|
||||
@@ -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<string, PosixShellType>([
|
||||
['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<string>());
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user