mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-27 14:59:57 +00:00
added hotkeys to open specific profiles
This commit is contained in:
parent
128aa618f0
commit
1675312f75
@ -6,6 +6,9 @@ export class TerminalConfigProvider extends ConfigProvider {
|
|||||||
shell: {
|
shell: {
|
||||||
__nonStructural: true,
|
__nonStructural: true,
|
||||||
},
|
},
|
||||||
|
profile: {
|
||||||
|
__nonStructural: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
terminal: {
|
terminal: {
|
||||||
frontend: 'xterm',
|
frontend: 'xterm',
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
import slug from 'slug'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { IHotkeyDescription, HotkeyProvider } from 'terminus-core'
|
import { IHotkeyDescription, HotkeyProvider, ConfigService } from 'terminus-core'
|
||||||
import { TerminalService } from './services/terminal.service'
|
import { TerminalService } from './services/terminal.service'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -64,14 +65,22 @@ export class TerminalHotkeyProvider extends HotkeyProvider {
|
|||||||
]
|
]
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
|
private config: ConfigService,
|
||||||
private terminal: TerminalService,
|
private terminal: TerminalService,
|
||||||
) { super() }
|
) { super() }
|
||||||
|
|
||||||
async provide (): Promise<IHotkeyDescription[]> {
|
async provide (): Promise<IHotkeyDescription[]> {
|
||||||
let shells = await this.terminal.shells$.toPromise()
|
let shells = await this.terminal.shells$.toPromise()
|
||||||
return this.hotkeys.concat(shells.map(shell => ({
|
return [
|
||||||
|
...this.hotkeys,
|
||||||
|
...shells.map(shell => ({
|
||||||
id: `shell.${shell.id}`,
|
id: `shell.${shell.id}`,
|
||||||
name: `New tab: ${shell.name}`
|
name: `New tab: ${shell.name}`
|
||||||
})))
|
})),
|
||||||
|
...this.config.store.terminal.profiles.map(profile => ({
|
||||||
|
id: `profile.${slug(profile.name)}`,
|
||||||
|
name: `New tab: ${profile.name}`
|
||||||
|
})),
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import * as fs from 'mz/fs'
|
import * as fs from 'mz/fs'
|
||||||
|
import slug from 'slug'
|
||||||
|
|
||||||
import { NgModule } from '@angular/core'
|
import { NgModule } from '@angular/core'
|
||||||
import { BrowserModule } from '@angular/platform-browser'
|
import { BrowserModule } from '@angular/platform-browser'
|
||||||
@ -166,6 +167,13 @@ export default class TerminalModule {
|
|||||||
terminal.openTab(shell)
|
terminal.openTab(shell)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (hotkey.startsWith('profile.')) {
|
||||||
|
let profiles = config.store.terminal.profiles
|
||||||
|
let profile = profiles.find(x => slug(x.name) === hotkey.split('.')[1])
|
||||||
|
if (profile) {
|
||||||
|
terminal.openTabWithOptions(profile.sessionOptions)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
hostApp.cliOpenDirectory$.subscribe(async directory => {
|
hostApp.cliOpenDirectory$.subscribe(async directory => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user