mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-30 08:19:54 +00:00
profile settings tab
This commit is contained in:
parent
1f1d212c1d
commit
72287cc7cb
@ -111,6 +111,13 @@ export class TabHeaderComponent {
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
if ((this.tab as any).saveAsProfile) {
|
||||||
|
contextMenu.append(new this.electron.MenuItem({
|
||||||
|
label: 'Save as a profile',
|
||||||
|
click: () => this.zone.run(() => (this.tab as any).saveAsProfile())
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
let process = await this.tab.getCurrentProcess()
|
let process = await this.tab.getCurrentProcess()
|
||||||
if (process) {
|
if (process) {
|
||||||
contextMenu.append(new this.electron.MenuItem({
|
contextMenu.append(new this.electron.MenuItem({
|
||||||
|
@ -23,6 +23,11 @@ export interface SessionOptions {
|
|||||||
pauseAfterExit?: boolean
|
pauseAfterExit?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Profile {
|
||||||
|
name: string,
|
||||||
|
sessionOptions: SessionOptions,
|
||||||
|
}
|
||||||
|
|
||||||
export interface ITerminalColorScheme {
|
export interface ITerminalColorScheme {
|
||||||
name: string
|
name: string
|
||||||
foreground: string
|
foreground: string
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
h3 Saved Profiles
|
||||||
|
|
||||||
|
.list-group.mt-3.mb-3
|
||||||
|
.list-group-item.list-item-group-action.d-flex.align-items-center(
|
||||||
|
*ngFor='let profile of profiles',
|
||||||
|
(click)='editProfile(profile)',
|
||||||
|
)
|
||||||
|
.mr-auto
|
||||||
|
div {{profile.name}}
|
||||||
|
.text-muted {{profile.description}}
|
||||||
|
button.btn.btn-outline-danger.ml-1((click)='$event.stopPropagation(); deleteProfile(profile)')
|
||||||
|
i.fa.fa-trash-o
|
||||||
|
|
||||||
|
.text-muted To add a new profile, right-click a tab and select "Save as a profile"
|
@ -0,0 +1,25 @@
|
|||||||
|
import { Component } from '@angular/core'
|
||||||
|
import { ConfigService } from 'terminus-core'
|
||||||
|
import { Profile } from '../api'
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
template: require('./profilesSettingsTab.component.pug'),
|
||||||
|
})
|
||||||
|
export class ProfilesSettingsTabComponent {
|
||||||
|
profiles: Profile[] = []
|
||||||
|
|
||||||
|
constructor (
|
||||||
|
private config: ConfigService,
|
||||||
|
) {
|
||||||
|
this.profiles = config.store.terminal.profiles
|
||||||
|
}
|
||||||
|
|
||||||
|
async ngOnInit () {
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteProfile (profile: Profile) {
|
||||||
|
this.profiles = this.profiles.filter(x => x !== profile)
|
||||||
|
this.config.store.terminal.profiles = this.profiles
|
||||||
|
this.config.save()
|
||||||
|
}
|
||||||
|
}
|
@ -41,7 +41,7 @@ h3.mb-3 Shell
|
|||||||
button.btn.btn-secondary((click)='pickWorkingDirectory()')
|
button.btn.btn-secondary((click)='pickWorkingDirectory()')
|
||||||
i.fa.fa-folder-open
|
i.fa.fa-folder-open
|
||||||
|
|
||||||
.form-line
|
.form-line.align-items-start
|
||||||
.header
|
.header
|
||||||
.title Environment
|
.title Environment
|
||||||
.description Inject additional environment variables
|
.description Inject additional environment variables
|
||||||
|
@ -4,7 +4,6 @@ import { ToastrService } from 'ngx-toastr'
|
|||||||
import { Component, NgZone, Inject, Optional, ViewChild, HostBinding, Input } from '@angular/core'
|
import { Component, NgZone, Inject, Optional, ViewChild, HostBinding, Input } from '@angular/core'
|
||||||
import { AppService, ConfigService, BaseTabComponent, BaseTabProcess, ElectronService, HostAppService, HotkeysService, Platform } from 'terminus-core'
|
import { AppService, ConfigService, BaseTabComponent, BaseTabProcess, ElectronService, HostAppService, HotkeysService, Platform } from 'terminus-core'
|
||||||
|
|
||||||
import { IShell } from '../api'
|
|
||||||
import { Session, SessionsService } from '../services/sessions.service'
|
import { Session, SessionsService } from '../services/sessions.service'
|
||||||
import { TerminalService } from '../services/terminal.service'
|
import { TerminalService } from '../services/terminal.service'
|
||||||
import { TerminalFrontendService } from '../services/terminalFrontend.service'
|
import { TerminalFrontendService } from '../services/terminalFrontend.service'
|
||||||
@ -33,10 +32,8 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
sessionCloseSubscription: Subscription
|
sessionCloseSubscription: Subscription
|
||||||
hotkeysSubscription: Subscription
|
hotkeysSubscription: Subscription
|
||||||
htermVisible = false
|
htermVisible = false
|
||||||
shell: IShell
|
|
||||||
private output = new Subject<string>()
|
private output = new Subject<string>()
|
||||||
private bellPlayer: HTMLAudioElement
|
private bellPlayer: HTMLAudioElement
|
||||||
private contextMenu: any
|
|
||||||
private termContainerSubscriptions: Subscription[] = []
|
private termContainerSubscriptions: Subscription[] = []
|
||||||
|
|
||||||
get input$ (): Observable<string> { return this.frontend.input$ }
|
get input$ (): Observable<string> { return this.frontend.input$ }
|
||||||
@ -203,14 +200,28 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
this.contextMenu = [
|
this.frontend.focus()
|
||||||
|
}
|
||||||
|
|
||||||
|
buildContextMenu (): Electron.MenuItemConstructorOptions[] {
|
||||||
|
return [
|
||||||
{
|
{
|
||||||
label: 'New terminal',
|
label: 'New terminal',
|
||||||
click: () => {
|
click: () => this.zone.run(() => {
|
||||||
this.zone.run(() => {
|
this.terminalService.openTabWithOptions(this.sessionOptions)
|
||||||
this.terminalService.openTab(this.shell)
|
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
label: 'New from profile',
|
||||||
|
submenu: this.config.store.terminal.profiles.length ? this.config.store.terminal.profiles.map(profile => ({
|
||||||
|
label: profile.name,
|
||||||
|
click: () => this.zone.run(() => {
|
||||||
|
this.terminalService.openTabWithOptions(profile.sessionOptions)
|
||||||
|
}),
|
||||||
|
})) : [{
|
||||||
|
label: 'No profiles saved',
|
||||||
|
enabled: false,
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Copy',
|
label: 'Copy',
|
||||||
@ -232,8 +243,6 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
this.frontend.focus()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
detachTermContainerHandlers () {
|
detachTermContainerHandlers () {
|
||||||
@ -255,7 +264,7 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
if (event.type === 'mousedown') {
|
if (event.type === 'mousedown') {
|
||||||
if (event.which === 3) {
|
if (event.which === 3) {
|
||||||
if (this.config.store.terminal.rightClick === 'menu') {
|
if (this.config.store.terminal.rightClick === 'menu') {
|
||||||
this.hostApp.popupContextMenu(this.contextMenu)
|
this.hostApp.popupContextMenu(this.buildContextMenu())
|
||||||
} else if (this.config.store.terminal.rightClick === 'paste') {
|
} else if (this.config.store.terminal.rightClick === 'paste') {
|
||||||
this.paste()
|
this.paste()
|
||||||
}
|
}
|
||||||
@ -400,4 +409,20 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
}
|
}
|
||||||
return confirm(`"${children[0].command}" is still running. Close?`)
|
return confirm(`"${children[0].command}" is still running. Close?`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async saveAsProfile () {
|
||||||
|
let profile = {
|
||||||
|
sessionOptions: {
|
||||||
|
...this.sessionOptions,
|
||||||
|
cwd: (await this.session.getWorkingDirectory()) || this.sessionOptions.cwd,
|
||||||
|
},
|
||||||
|
name: this.sessionOptions.command,
|
||||||
|
}
|
||||||
|
this.config.store.terminal.profiles = [
|
||||||
|
...this.config.store.terminal.profiles,
|
||||||
|
profile,
|
||||||
|
]
|
||||||
|
this.config.save()
|
||||||
|
this.toastr.info('Saved')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ export class TerminalConfigProvider extends ConfigProvider {
|
|||||||
},
|
},
|
||||||
customColorSchemes: [],
|
customColorSchemes: [],
|
||||||
environment: {},
|
environment: {},
|
||||||
|
profiles: [],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,14 @@ export class HTermFrontend extends Frontend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private setFontSize () {
|
private setFontSize () {
|
||||||
preferenceManager.set('font-size', this.configuredFontSize * Math.pow(1.1, this.zoom))
|
let size = this.configuredFontSize * Math.pow(1.1, this.zoom)
|
||||||
|
preferenceManager.set('font-size', size)
|
||||||
|
if (this.term) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.term.scrollPort_.characterSize = this.term.scrollPort_.measureCharacterSize()
|
||||||
|
this.term.setFontSize(size)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private init () {
|
private init () {
|
||||||
|
@ -13,6 +13,7 @@ import { SettingsTabProvider } from 'terminus-settings'
|
|||||||
|
|
||||||
import { AppearanceSettingsTabComponent } from './components/appearanceSettingsTab.component'
|
import { AppearanceSettingsTabComponent } from './components/appearanceSettingsTab.component'
|
||||||
import { ShellSettingsTabComponent } from './components/shellSettingsTab.component'
|
import { ShellSettingsTabComponent } from './components/shellSettingsTab.component'
|
||||||
|
import { ProfilesSettingsTabComponent } from './components/profilesSettingsTab.component'
|
||||||
import { TerminalTabComponent } from './components/terminalTab.component'
|
import { TerminalTabComponent } from './components/terminalTab.component'
|
||||||
import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.component'
|
import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.component'
|
||||||
import { ColorPickerComponent } from './components/colorPicker.component'
|
import { ColorPickerComponent } from './components/colorPicker.component'
|
||||||
@ -24,7 +25,7 @@ import { TerminalService } from './services/terminal.service'
|
|||||||
import { ButtonProvider } from './buttonProvider'
|
import { ButtonProvider } from './buttonProvider'
|
||||||
import { RecoveryProvider } from './recoveryProvider'
|
import { RecoveryProvider } from './recoveryProvider'
|
||||||
import { TerminalColorSchemeProvider, TerminalDecorator, ShellProvider } from './api'
|
import { TerminalColorSchemeProvider, TerminalDecorator, ShellProvider } from './api'
|
||||||
import { TerminalSettingsTabProvider, AppearanceSettingsTabProvider, ShellSettingsTabProvider } from './settings'
|
import { TerminalSettingsTabProvider, AppearanceSettingsTabProvider, ShellSettingsTabProvider, ProfilesSettingsTabProvider } from './settings'
|
||||||
import { PathDropDecorator } from './pathDrop'
|
import { PathDropDecorator } from './pathDrop'
|
||||||
import { TerminalConfigProvider } from './config'
|
import { TerminalConfigProvider } from './config'
|
||||||
import { TerminalHotkeyProvider } from './hotkeys'
|
import { TerminalHotkeyProvider } from './hotkeys'
|
||||||
@ -60,6 +61,7 @@ import { hterm } from './hterm'
|
|||||||
|
|
||||||
{ provide: SettingsTabProvider, useClass: AppearanceSettingsTabProvider, multi: true },
|
{ provide: SettingsTabProvider, useClass: AppearanceSettingsTabProvider, multi: true },
|
||||||
{ provide: SettingsTabProvider, useClass: ShellSettingsTabProvider, multi: true },
|
{ provide: SettingsTabProvider, useClass: ShellSettingsTabProvider, multi: true },
|
||||||
|
{ provide: SettingsTabProvider, useClass: ProfilesSettingsTabProvider, multi: true },
|
||||||
{ provide: SettingsTabProvider, useClass: TerminalSettingsTabProvider, multi: true },
|
{ provide: SettingsTabProvider, useClass: TerminalSettingsTabProvider, multi: true },
|
||||||
|
|
||||||
{ provide: ToolbarButtonProvider, useClass: ButtonProvider, multi: true },
|
{ provide: ToolbarButtonProvider, useClass: ButtonProvider, multi: true },
|
||||||
@ -91,6 +93,7 @@ import { hterm } from './hterm'
|
|||||||
TerminalTabComponent,
|
TerminalTabComponent,
|
||||||
AppearanceSettingsTabComponent,
|
AppearanceSettingsTabComponent,
|
||||||
ShellSettingsTabComponent,
|
ShellSettingsTabComponent,
|
||||||
|
ProfilesSettingsTabComponent,
|
||||||
TerminalSettingsTabComponent,
|
TerminalSettingsTabComponent,
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -98,6 +101,7 @@ import { hterm } from './hterm'
|
|||||||
TerminalTabComponent,
|
TerminalTabComponent,
|
||||||
AppearanceSettingsTabComponent,
|
AppearanceSettingsTabComponent,
|
||||||
ShellSettingsTabComponent,
|
ShellSettingsTabComponent,
|
||||||
|
ProfilesSettingsTabComponent,
|
||||||
TerminalSettingsTabComponent,
|
TerminalSettingsTabComponent,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Observable, AsyncSubject } from 'rxjs'
|
import { Observable, AsyncSubject } from 'rxjs'
|
||||||
import { Injectable, Inject } from '@angular/core'
|
import { Injectable, Inject } from '@angular/core'
|
||||||
import { AppService, Logger, LogService, ConfigService } from 'terminus-core'
|
import { AppService, Logger, LogService, ConfigService } from 'terminus-core'
|
||||||
import { IShell, ShellProvider } from '../api'
|
import { IShell, ShellProvider, SessionOptions } from '../api'
|
||||||
import { TerminalTabComponent } from '../components/terminalTab.component'
|
import { TerminalTabComponent } from '../components/terminalTab.component'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -60,11 +60,15 @@ export class TerminalService {
|
|||||||
pauseAfterExit: pause,
|
pauseAfterExit: pause,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this.openTabWithOptions(sessionOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
openTabWithOptions (sessionOptions: SessionOptions): TerminalTabComponent {
|
||||||
this.logger.log('Using session options:', sessionOptions)
|
this.logger.log('Using session options:', sessionOptions)
|
||||||
|
|
||||||
return this.app.openNewTab(
|
return this.app.openNewTab(
|
||||||
TerminalTabComponent,
|
TerminalTabComponent,
|
||||||
{ sessionOptions, shell }
|
{ sessionOptions }
|
||||||
) as TerminalTabComponent
|
) as TerminalTabComponent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import { SettingsTabProvider } from 'terminus-settings'
|
|||||||
import { AppearanceSettingsTabComponent } from './components/appearanceSettingsTab.component'
|
import { AppearanceSettingsTabComponent } from './components/appearanceSettingsTab.component'
|
||||||
import { ShellSettingsTabComponent } from './components/shellSettingsTab.component'
|
import { ShellSettingsTabComponent } from './components/shellSettingsTab.component'
|
||||||
import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.component'
|
import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.component'
|
||||||
|
import { ProfilesSettingsTabComponent } from './components/profilesSettingsTab.component'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AppearanceSettingsTabProvider extends SettingsTabProvider {
|
export class AppearanceSettingsTabProvider extends SettingsTabProvider {
|
||||||
@ -34,3 +35,13 @@ export class TerminalSettingsTabProvider extends SettingsTabProvider {
|
|||||||
return TerminalSettingsTabComponent
|
return TerminalSettingsTabComponent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ProfilesSettingsTabProvider extends SettingsTabProvider {
|
||||||
|
id = 'profiles'
|
||||||
|
title = 'Profiles'
|
||||||
|
|
||||||
|
getComponentType (): any {
|
||||||
|
return ProfilesSettingsTabComponent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user