mirror of
https://github.com/Eugeny/tabby.git
synced 2025-04-12 16:10:26 +08:00
custom shells (fixes #50)
This commit is contained in:
parent
0fe7edc5b5
commit
fb64ca08d3
@ -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
|
||||
|
@ -10,6 +10,7 @@ export class TerminalConfigProvider extends ConfigProvider {
|
||||
background: 'theme',
|
||||
ligatures: false,
|
||||
cursor: 'block',
|
||||
customShell: '',
|
||||
colorScheme: {
|
||||
__nonStructural: true,
|
||||
name: 'Material',
|
||||
|
@ -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 },
|
||||
|
@ -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()
|
||||
|
21
terminus-terminal/src/shells/custom.ts
Normal file
21
terminus-terminal/src/shells/custom.ts
Normal 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
|
||||
}]
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user