sensible shell defaults for Windows (fixes #431)

This commit is contained in:
Eugene Pankov
2018-09-22 11:48:51 +02:00
parent 6b08341760
commit 507b69acb4
3 changed files with 60 additions and 3 deletions

View File

@@ -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<IShell[]> {
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 []
}
}

View File

@@ -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',