Skip to content

Instantly share code, notes, and snippets.

@vince-fugnitto
Created May 22, 2019 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vince-fugnitto/1d0590adaa48eddcfdb02bb6877cfb03 to your computer and use it in GitHub Desktop.
Save vince-fugnitto/1d0590adaa48eddcfdb02bb6877cfb03 to your computer and use it in GitHub Desktop.
import { injectable, inject } from 'inversify';
import { FrontendApplicationContribution, FrontendApplication } from '@theia/core/lib/browser';
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service';
import { TerminalWidget } from '@theia/terminal/lib/browser/base/terminal-widget';
@injectable()
export class TerminalStartContribution implements FrontendApplicationContribution {
@inject(FrontendApplicationStateService)
protected readonly stateService: FrontendApplicationStateService;
@inject(TerminalService)
protected readonly terminalService: TerminalService;
protected readonly TERMINAL_ID = 'start:terminal:id'
async onStart(app: FrontendApplication): Promise<void> {
this.stateService.reachedState('ready').then(
async () => {
// Determine if a terminal currently exists, else skip.
if (this.terminalService.getById(this.TERMINAL_ID)) {
return;
}
// Create a new terminal, start it and activate it.
const terminal = await this.createTerminal();
await terminal.start();
this.terminalService.activateTerminal(terminal);
}
);
}
protected async createTerminal(): Promise<TerminalWidget> {
const terminal = await this.terminalService.newTerminal({
id: this.TERMINAL_ID,
title: 'Vince',
destroyTermOnClose: true,
useServerTitle: false,
});
return terminal;
}
}
@arnonrdp
Copy link

Update:

On line 29: activateTerminal() no longer exists in terminalService.
Instead, use open():

this.terminalService.open(terminal);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment