mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 02:18:01 +00:00
hotkeys for specific shells
This commit is contained in:
@@ -2,6 +2,11 @@ import { ConfigProvider, Platform } from 'terminus-core'
|
||||
|
||||
export class TerminalConfigProvider extends ConfigProvider {
|
||||
defaults = {
|
||||
hotkeys: {
|
||||
shell: {
|
||||
__nonStructural: true,
|
||||
},
|
||||
},
|
||||
terminal: {
|
||||
frontend: 'hterm',
|
||||
autoOpen: false,
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { IHotkeyDescription, HotkeyProvider } from 'terminus-core'
|
||||
import { TerminalService } from './services/terminal.service'
|
||||
|
||||
@Injectable()
|
||||
export class TerminalHotkeyProvider extends HotkeyProvider {
|
||||
@@ -61,4 +62,16 @@ export class TerminalHotkeyProvider extends HotkeyProvider {
|
||||
name: 'Intelligent Ctrl-C (copy/abort)',
|
||||
},
|
||||
]
|
||||
|
||||
constructor (
|
||||
private terminal: TerminalService,
|
||||
) { super() }
|
||||
|
||||
async provide (): Promise<IHotkeyDescription[]> {
|
||||
let shells = await this.terminal.shells$.toPromise()
|
||||
return this.hotkeys.concat(shells.map(shell => ({
|
||||
id: `shell.${shell.id}`,
|
||||
name: `New tab: ${shell.name}`
|
||||
})))
|
||||
}
|
||||
}
|
||||
|
@@ -148,11 +148,16 @@ export default class TerminalModule {
|
||||
if (hotkey === 'new-tab') {
|
||||
terminal.openTab()
|
||||
}
|
||||
})
|
||||
hotkeys.matchedHotkey.subscribe(async (hotkey) => {
|
||||
if (hotkey === 'new-window') {
|
||||
hostApp.newWindow()
|
||||
}
|
||||
if (hotkey.startsWith('shell.')) {
|
||||
let shells = await terminal.shells$
|
||||
let shell = shells.find(x => x.id === hotkey.split('.')[1])
|
||||
if (shell) {
|
||||
terminal.openTab(shell)
|
||||
}
|
||||
}
|
||||
})
|
||||
hostApp.cliOpenDirectory$.subscribe(async directory => {
|
||||
if (await fs.exists(directory)) {
|
||||
|
@@ -27,10 +27,14 @@ export class TerminalService {
|
||||
})
|
||||
}
|
||||
|
||||
async getShells (): Promise<IShell[]> {
|
||||
let shellLists = await Promise.all(this.config.enabledServices(this.shellProviders).map(x => x.provide()))
|
||||
return shellLists.reduce((a, b) => a.concat(b))
|
||||
}
|
||||
|
||||
async reloadShells () {
|
||||
this.shells = new AsyncSubject<IShell[]>()
|
||||
let shellLists = await Promise.all(this.config.enabledServices(this.shellProviders).map(x => x.provide()))
|
||||
this.shells.next(shellLists.reduce((a, b) => a.concat(b)))
|
||||
this.shells.next(await this.getShells())
|
||||
this.shells.complete()
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,7 @@ export class CustomShellProvider extends ShellProvider {
|
||||
let args = this.config.store.terminal.customShell.split(' ')
|
||||
return [{
|
||||
id: 'custom',
|
||||
name: 'Custom',
|
||||
name: 'Custom shell',
|
||||
command: args[0],
|
||||
args: args.slice(1),
|
||||
}]
|
||||
|
Reference in New Issue
Block a user