How to use @jupyterlab/terminal - 10 common examples

To help you get started, we’ve selected a few @jupyterlab/terminal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab / examples / terminal / src / index.ts View on Github external
async function main(): Promise {
  let dock = new DockPanel();
  dock.id = 'main';

  // Attach the widget to the dom.
  Widget.attach(dock, document.body);

  // Handle resize events.
  window.addEventListener('resize', () => {
    dock.fit();
  });

  const manager = new TerminalManager();
  const s1 = await manager.startNew();
  const term1 = new Terminal(s1, { theme: 'light' });
  term1.title.closable = true;
  dock.addWidget(term1);

  const s2 = await manager.startNew();
  const term2 = new Terminal(s2, { theme: 'dark' });
  term2.title.closable = true;
  dock.addWidget(term2, { mode: 'tab-before' });

  console.log('Example started!');
}
github jupyterlab / jupyterlab / examples / terminal / src / index.ts View on Github external
// Attach the widget to the dom.
  Widget.attach(dock, document.body);

  // Handle resize events.
  window.addEventListener('resize', () => {
    dock.fit();
  });

  const manager = new TerminalManager();
  const s1 = await manager.startNew();
  const term1 = new Terminal(s1, { theme: 'light' });
  term1.title.closable = true;
  dock.addWidget(term1);

  const s2 = await manager.startNew();
  const term2 = new Terminal(s2, { theme: 'dark' });
  term2.title.closable = true;
  dock.addWidget(term2, { mode: 'tab-before' });

  console.log('Example started!');
}
github ryantam626 / jupyterlab_black / src / index.ts View on Github external
private async setupTerminalSession() {
        // Abort if somehow no terminals available.
        if (!this.app.serviceManager.terminals.isAvailable()) {
            // tslint:disable-next-line:no-console
            console.log("Disabling jupyterlab_black plugin because lack of terminal access.");
            this.loaded = false;
            return;
        }

        this.term = new Terminal();

        try {
            this.term.session = await this.app.serviceManager.terminals.startNew();
            // NOTE: unset HISTFILE so user's shell history is no longer as polluted
            //       when we dump codecell content though terminal.
            this.term.session.send({type: "stdin", content: ["unset HISTFILE\r"]});
            this.loaded = true;
            // tslint:disable-next-line:no-console
            console.log("Terminal session started.", this.term.session.name);
        } catch (e) {
            this.term.dispose();
            this.term = undefined;
            this.loaded = false;
        }
    }
github mlshapiro / jupyterlab-flake8 / src / index.ts View on Github external
async load_linter(){

    // Bail if there are no terminals available.
    if (!this.app.serviceManager.terminals.isAvailable()) {
      console.log('Disabling jupyterlab-flake8 plugin because it cant access terminal');
      this.loaded = false;
      this.toggled = false;
      return;
    }

    this.term = new Terminal();
    try {
      this.term.session = await this.app.serviceManager.terminals.startNew();
      console.log('loaded terminal session');

      // wait 2 seconds for terminal to load and get initial commands out of its system
      setTimeout(() => {
        this.check_flake8();
      }, 2000)
    }
    catch(e) {
      this.term.dispose();
      this.term = undefined;
    }
  }
github jupyterlab / jupyterlab-data-explorer / jupyterlab / examples / terminal / src / index.ts View on Github external
function main(): void {
  let term1 = new Terminal({ theme: 'light' });
  let term2 = new Terminal({ theme: 'dark' });

  TerminalSession.startNew().then(session => {
    term1.session = session;
  });
  TerminalSession.startNew().then(session => {
    term2.session = session;
  });

  term1.title.closable = true;
  term2.title.closable = true;
  let dock = new DockPanel();
  dock.addWidget(term1);
  dock.addWidget(term2, { mode: 'tab-before' });
  dock.id = 'main';

  // Attach the widget to the dom.
github jupyterlab / jupyterlab / packages / terminal-extension / src / index.ts View on Github external
execute: args => {
      let name = args ? args['name'] as string : '';
      let term = new Terminal();
      term.title.closable = true;
      term.title.icon = TERMINAL_ICON_CLASS;
      term.title.label = '...';
      shell.addToMainArea(term);

      let promise = name ?
        services.terminals.connectTo(name)
        : services.terminals.startNew();

      return promise.then(session => {
        term.session = session;
        tracker.add(term);
        shell.activateById(term.id);
        return term;
      }).catch(() => { term.dispose(); });
    }
github jupyterlab / jupyterlab-data-explorer / jupyterlab / examples / terminal / src / index.ts View on Github external
function main(): void {
  let term1 = new Terminal({ theme: 'light' });
  let term2 = new Terminal({ theme: 'dark' });

  TerminalSession.startNew().then(session => {
    term1.session = session;
  });
  TerminalSession.startNew().then(session => {
    term2.session = session;
  });

  term1.title.closable = true;
  term2.title.closable = true;
  let dock = new DockPanel();
  dock.addWidget(term1);
  dock.addWidget(term2, { mode: 'tab-before' });
  dock.id = 'main';
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / terminal-extension / src / index.ts View on Github external
    isToggled: args => args['theme'] === ITerminal.defaultOptions.theme,
    execute: async args => {
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / terminal-extension / src / index.ts View on Github external
execute: async () => {
      let { fontSize } = ITerminal.defaultOptions;
      if (fontSize < 72) {
        try {
          await settingRegistry.set(plugin.id, 'fontSize', fontSize + 1);
        } catch (err) {
          Private.showErrorMessage(err);
        }
      }
    }
  });
github jupyterlab / jupyterlab / packages / terminal-extension / src / index.ts View on Github external
execute: () => {
      let options = Terminal.defaultOptions;
      if (options.fontSize < 72) {
        options.fontSize++;
        tracker.forEach(widget => { widget.fontSize = options.fontSize; });
      }
    },
    isEnabled: hasWidget

@jupyterlab/terminal

JupyterLab - Terminal Emulator Widget

BSD-3-Clause
Latest version published 6 days ago

Package Health Score

93 / 100
Full package analysis