custom shells (fixes #50)

This commit is contained in:
Eugene Pankov 2017-10-07 17:27:58 +02:00
parent 0fe7edc5b5
commit fb64ca08d3
5 changed files with 44 additions and 4 deletions

View File

@ -238,6 +238,14 @@
[ngValue]='shell.id'
) {{shell.name}}
.form-group(*ngIf='config.store.terminal.shell == "custom"')
label Custom shell
input.form-control(
type='text',
'[(ngModel)]'='config.store.terminal.customShell',
(ngModelChange)='config.save()',
)
.form-group
label Terminal bell
br

View File

@ -10,6 +10,7 @@ export class TerminalConfigProvider extends ConfigProvider {
background: 'theme',
ligatures: false,
cursor: 'block',
customShell: '',
colorScheme: {
__nonStructural: true,
name: 'Material',

View File

@ -24,6 +24,7 @@ import { TerminalConfigProvider } from './config'
import { TerminalHotkeyProvider } from './hotkeys'
import { HyperColorSchemes } from './colorSchemes'
import { CustomShellProvider } from './shells/custom'
import { Cygwin32ShellProvider } from './shells/cygwin32'
import { Cygwin64ShellProvider } from './shells/cygwin64'
import { GitBashShellProvider } from './shells/gitBash'
@ -59,6 +60,7 @@ import { hterm } from './hterm'
{ provide: ShellProvider, useClass: WindowsStockShellsProvider, multi: true },
{ provide: ShellProvider, useClass: MacOSDefaultShellProvider, multi: true },
{ provide: ShellProvider, useClass: LinuxDefaultShellProvider, multi: true },
{ provide: ShellProvider, useClass: CustomShellProvider, multi: true },
{ provide: ShellProvider, useClass: Cygwin32ShellProvider, multi: true },
{ provide: ShellProvider, useClass: Cygwin64ShellProvider, multi: true },
{ provide: ShellProvider, useClass: GitBashShellProvider, multi: true },

View File

@ -14,16 +14,24 @@ export class TerminalService {
private app: AppService,
private sessions: SessionsService,
private config: ConfigService,
@Inject(ShellProvider) shellProviders: ShellProvider[],
@Inject(ShellProvider) private shellProviders: ShellProvider[],
log: LogService,
) {
this.logger = log.create('terminal')
Promise.all(shellProviders.map(x => x.provide())).then(shellLists => {
this.shells$.next(shellLists.reduce((a, b) => a.concat(b)))
this.shells$.complete()
this.reloadShells()
config.changed$.subscribe(() => {
this.reloadShells()
})
}
async reloadShells () {
this.shells$ = new AsyncSubject<IShell[]>()
let shellLists = await Promise.all(this.shellProviders.map(x => x.provide()))
this.shells$.next(shellLists.reduce((a, b) => a.concat(b)))
this.shells$.complete()
}
async openTab (shell?: IShell, cwd?: string): Promise<TerminalTabComponent> {
if (!cwd && this.app.activeTab instanceof TerminalTabComponent) {
cwd = await this.app.activeTab.session.getWorkingDirectory()

View File

@ -0,0 +1,21 @@
import { Injectable } from '@angular/core'
import { ConfigService } from 'terminus-core'
import { ShellProvider, IShell } from '../api'
@Injectable()
export class CustomShellProvider extends ShellProvider {
constructor (
private config: ConfigService,
) {
super()
}
async provide (): Promise<IShell[]> {
return [{
id: 'custom',
name: 'Custom',
command: this.config.store.terminal.customShell
}]
}
}