mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-24 02:53:43 +03:00
sensible shell defaults for Windows (fixes #431)
This commit is contained in:
parent
6b08341760
commit
507b69acb4
@ -36,6 +36,7 @@ import { LinuxDefaultShellProvider } from './shells/linuxDefault'
|
|||||||
import { MacOSDefaultShellProvider } from './shells/macDefault'
|
import { MacOSDefaultShellProvider } from './shells/macDefault'
|
||||||
import { POSIXShellsProvider } from './shells/posix'
|
import { POSIXShellsProvider } from './shells/posix'
|
||||||
import { PowerShellCoreShellProvider } from './shells/powershellCore'
|
import { PowerShellCoreShellProvider } from './shells/powershellCore'
|
||||||
|
import { WindowsDefaultShellProvider } from './shells/winDefault'
|
||||||
import { WindowsStockShellsProvider } from './shells/windowsStock'
|
import { WindowsStockShellsProvider } from './shells/windowsStock'
|
||||||
import { WSLShellProvider } from './shells/wsl'
|
import { WSLShellProvider } from './shells/wsl'
|
||||||
|
|
||||||
@ -65,10 +66,11 @@ import { hterm } from './hterm'
|
|||||||
{ provide: SessionPersistenceProvider, useClass: ScreenPersistenceProvider, multi: true },
|
{ provide: SessionPersistenceProvider, useClass: ScreenPersistenceProvider, multi: true },
|
||||||
{ provide: SessionPersistenceProvider, useClass: TMuxPersistenceProvider, multi: true },
|
{ provide: SessionPersistenceProvider, useClass: TMuxPersistenceProvider, multi: true },
|
||||||
|
|
||||||
{ provide: ShellProvider, useClass: CmderShellProvider, multi: true },
|
{ provide: ShellProvider, useClass: WindowsDefaultShellProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: WindowsStockShellsProvider, multi: true },
|
|
||||||
{ provide: ShellProvider, useClass: MacOSDefaultShellProvider, multi: true },
|
{ provide: ShellProvider, useClass: MacOSDefaultShellProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: LinuxDefaultShellProvider, 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: CustomShellProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: Cygwin32ShellProvider, multi: true },
|
{ provide: ShellProvider, useClass: Cygwin32ShellProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: Cygwin64ShellProvider, 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: POSIXShellsProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: PowerShellCoreShellProvider, multi: true },
|
{ provide: ShellProvider, useClass: PowerShellCoreShellProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: WSLShellProvider, multi: true },
|
{ provide: ShellProvider, useClass: WSLShellProvider, multi: true },
|
||||||
|
|
||||||
|
// For WindowsDefaultShellProvider
|
||||||
|
PowerShellCoreShellProvider,
|
||||||
|
WSLShellProvider,
|
||||||
|
WindowsStockShellsProvider
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
TerminalTabComponent,
|
TerminalTabComponent,
|
||||||
|
50
terminus-terminal/src/shells/winDefault.ts
Normal file
50
terminus-terminal/src/shells/winDefault.ts
Normal 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 []
|
||||||
|
}
|
||||||
|
}
|
@ -36,7 +36,7 @@ export class WindowsStockShellsProvider extends ShellProvider {
|
|||||||
{ id: 'cmd', name: 'CMD (stock)', command: 'cmd.exe' },
|
{ id: 'cmd', name: 'CMD (stock)', command: 'cmd.exe' },
|
||||||
{
|
{
|
||||||
id: 'powershell',
|
id: 'powershell',
|
||||||
name: 'Windows PowerShell',
|
name: 'PowerShell',
|
||||||
command: 'powershell.exe',
|
command: 'powershell.exe',
|
||||||
env: {
|
env: {
|
||||||
TERM: 'cygwin',
|
TERM: 'cygwin',
|
||||||
|
Loading…
Reference in New Issue
Block a user