diff --git a/terminus-terminal/src/config.ts b/terminus-terminal/src/config.ts index 3cba6b48..196e8f32 100644 --- a/terminus-terminal/src/config.ts +++ b/terminus-terminal/src/config.ts @@ -6,6 +6,9 @@ export class TerminalConfigProvider extends ConfigProvider { shell: { __nonStructural: true, }, + profile: { + __nonStructural: true, + }, }, terminal: { frontend: 'xterm', diff --git a/terminus-terminal/src/hotkeys.ts b/terminus-terminal/src/hotkeys.ts index 409a8f26..23e85179 100644 --- a/terminus-terminal/src/hotkeys.ts +++ b/terminus-terminal/src/hotkeys.ts @@ -1,5 +1,6 @@ +import slug from 'slug' import { Injectable } from '@angular/core' -import { IHotkeyDescription, HotkeyProvider } from 'terminus-core' +import { IHotkeyDescription, HotkeyProvider, ConfigService } from 'terminus-core' import { TerminalService } from './services/terminal.service' @Injectable() @@ -64,14 +65,22 @@ export class TerminalHotkeyProvider extends HotkeyProvider { ] constructor ( + private config: ConfigService, private terminal: TerminalService, ) { super() } async provide (): Promise { let shells = await this.terminal.shells$.toPromise() - return this.hotkeys.concat(shells.map(shell => ({ - id: `shell.${shell.id}`, - name: `New tab: ${shell.name}` - }))) + return [ + ...this.hotkeys, + ...shells.map(shell => ({ + id: `shell.${shell.id}`, + name: `New tab: ${shell.name}` + })), + ...this.config.store.terminal.profiles.map(profile => ({ + id: `profile.${slug(profile.name)}`, + name: `New tab: ${profile.name}` + })), + ] } } diff --git a/terminus-terminal/src/index.ts b/terminus-terminal/src/index.ts index 6ccfc62a..859c5f0a 100644 --- a/terminus-terminal/src/index.ts +++ b/terminus-terminal/src/index.ts @@ -1,4 +1,5 @@ import * as fs from 'mz/fs' +import slug from 'slug' import { NgModule } from '@angular/core' import { BrowserModule } from '@angular/platform-browser' @@ -166,6 +167,13 @@ export default class TerminalModule { 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 => {