diff --git a/terminus-terminal/src/index.ts b/terminus-terminal/src/index.ts index b085e648..7bde6ecc 100644 --- a/terminus-terminal/src/index.ts +++ b/terminus-terminal/src/index.ts @@ -36,6 +36,7 @@ import { LinuxDefaultShellProvider } from './shells/linuxDefault' import { MacOSDefaultShellProvider } from './shells/macDefault' import { POSIXShellsProvider } from './shells/posix' import { PowerShellCoreShellProvider } from './shells/powershellCore' +import { WindowsDefaultShellProvider } from './shells/winDefault' import { WindowsStockShellsProvider } from './shells/windowsStock' import { WSLShellProvider } from './shells/wsl' @@ -65,10 +66,11 @@ import { hterm } from './hterm' { provide: SessionPersistenceProvider, useClass: ScreenPersistenceProvider, multi: true }, { provide: SessionPersistenceProvider, useClass: TMuxPersistenceProvider, multi: true }, - { provide: ShellProvider, useClass: CmderShellProvider, multi: true }, - { provide: ShellProvider, useClass: WindowsStockShellsProvider, multi: true }, + { provide: ShellProvider, useClass: WindowsDefaultShellProvider, multi: true }, { provide: ShellProvider, useClass: MacOSDefaultShellProvider, multi: true }, { provide: ShellProvider, useClass: LinuxDefaultShellProvider, multi: true }, + { provide: ShellProvider, useClass: WindowsStockShellsProvider, multi: true }, + { provide: ShellProvider, useClass: CmderShellProvider, multi: true }, { provide: ShellProvider, useClass: CustomShellProvider, multi: true }, { provide: ShellProvider, useClass: Cygwin32ShellProvider, multi: true }, { provide: ShellProvider, useClass: Cygwin64ShellProvider, multi: true }, @@ -76,6 +78,11 @@ import { hterm } from './hterm' { provide: ShellProvider, useClass: POSIXShellsProvider, multi: true }, { provide: ShellProvider, useClass: PowerShellCoreShellProvider, multi: true }, { provide: ShellProvider, useClass: WSLShellProvider, multi: true }, + + // For WindowsDefaultShellProvider + PowerShellCoreShellProvider, + WSLShellProvider, + WindowsStockShellsProvider ], entryComponents: [ TerminalTabComponent, diff --git a/terminus-terminal/src/shells/winDefault.ts b/terminus-terminal/src/shells/winDefault.ts new file mode 100644 index 00000000..db923e73 --- /dev/null +++ b/terminus-terminal/src/shells/winDefault.ts @@ -0,0 +1,50 @@ +import { exec } from 'mz/child_process' +import { Injectable } from '@angular/core' +import { HostAppService, Platform } from 'terminus-core' + +import { ShellProvider, IShell } from '../api' + +import { WSLShellProvider } from './wsl' +import { PowerShellCoreShellProvider } from './powershellCore' +import { WindowsStockShellsProvider } from './windowsStock' + + +@Injectable() +export class WindowsDefaultShellProvider extends ShellProvider { + private providers: ShellProvider[] + + constructor ( + psc: PowerShellCoreShellProvider, + wsl: WSLShellProvider, + stock: WindowsStockShellsProvider, + private hostApp: HostAppService, + ) { + super() + this.providers = [ + psc + wsl, + stock, + ] + } + + async provide (): Promise { + if (this.hostApp.platform !== Platform.Windows) { + return [] + } + // Figure out a sensible default + let shellLists = await Promise.all(this.providers.map(x => x.provide())) + for (let list of shellLists) { + if (list.length) { + let shell = list[list.length - 1] + + return [{ + ...shell, + id: 'default', + name: 'User default', + }] + } + } + + return [] + } +} diff --git a/terminus-terminal/src/shells/windowsStock.ts b/terminus-terminal/src/shells/windowsStock.ts index 041c680b..cb81d60b 100644 --- a/terminus-terminal/src/shells/windowsStock.ts +++ b/terminus-terminal/src/shells/windowsStock.ts @@ -36,7 +36,7 @@ export class WindowsStockShellsProvider extends ShellProvider { { id: 'cmd', name: 'CMD (stock)', command: 'cmd.exe' }, { id: 'powershell', - name: 'Windows PowerShell', + name: 'PowerShell', command: 'powershell.exe', env: { TERM: 'cygwin',