Questions tagged [xtermjs]

xterm.js is a terminal emulator component written in JavaScript that works in the browser. Use this tag to ask questions about the usage and internals of xterm.js.

xterm.js

xterm.js build status Coverage Status Gitter


Xterm.js is a terminal emulator component written in JavaScript that works in the browser.

It enables applications to provide fully featured terminals to their users and create great development experiences.


Features

  • Text-based application support: Use xterm.js to work with applications like bash, git etc.
  • Curses-based application support: Use xterm.js to work with applications like vim, tmux etc.
  • Mouse events support: Xterm.js captures mouse events like click and scroll and passes them to the terminal's back-end controlling process
  • CJK (Chinese, Japanese, Korean) character support: Xterm.js renders CJK characters seamlessly
  • IME support: Insert international (including CJK) characters using IME input with your keyboard
  • Self-contained library: Xterm.js works on its own. It does not require any external libraries like jQuery or React to work
  • Modular, event-based API: Lets you build addons and themes with ease

What xterm.js is not

  • Xterm.js is not a terminal application that you can download and use on your computer
  • Xterm.js is not bash. Xterm.js can be connected to processes like bash and let you interact with them (provide input, receive output)

Getting Started

To start using xterm.js in a browser, add the xterm.js and xterm.css file into the head of your HTML page. Then create a <div id="terminal"></div> onto which xterm can attach itself.

<!doctype html>
  <html>
    <head>
      <link rel="stylesheet" href="bower_components/xterm.js/dist/xterm.css" />
      <script src="bower_components/xterm.js/dist/xterm.js"></script>
    </head>
    <body>
      <div id="terminal"></div>
      <script>
        var term = new Terminal();
        term.open(document.getElementById('terminal'));
        term.write('Hello from \033[1;3;31mxterm.js\033[0m $ ')
      </script>
    </body>
  </html>

Finally, instantiate the Terminal object and then call the open method with the DOM object of the div with id="terminal".

92 questions
29
votes
2 answers

How to create web based terminal using xterm.js to ssh into a system on local network

I came across this awesome library xterm.js which is also the base for Visual Studio Code's terminal. I have a very general question. I want to access a machine(ssh into a machine ) on a local network through a web based terminal(which is out of…
Ankit Kulkarni
  • 1,065
  • 3
  • 13
  • 23
24
votes
1 answer

How to make xterm.js accept input?

I'm using xterm.js for a project but I can't get it to accept input. Whenever I try to type in the terminal nothing happens and there's no documentation or examples telling how to accomplish this. This is what I have: const term = new XTerm({ …
corasan
  • 2,066
  • 3
  • 16
  • 35
11
votes
1 answer

How can I run an interactive program compiled with Emscripten in a web page?

I've got a simple program, say the following: #include int main() { char buf[100]; while (fgets(buf, sizeof(buf), stdin) != NULL) { printf("You typed: %s", buf); } } and I have compiled it using Emscripten: emcc -o…
Greg Hewgill
  • 828,234
  • 170
  • 1,097
  • 1,237
8
votes
1 answer

xterm.js - Getting current line text

I am developing a small xterm.js application (just getting started), and I am wondering how to get the text from the current line when the user presses enter. Here is the program: var term = new…
connectyourcharger
  • 1,322
  • 1
  • 11
  • 30
8
votes
1 answer

Blessed server (Node.js) over websocket to Xterm.js client in Browser

What I have: Node.js script running Blessed, and http/websocket server. Browser running Xterm.js and websocket client. What I want to do: Render blessed to the xterm window over websockets. Server Code: "use strict"; process.title =…
7
votes
4 answers

Integrate xterm.js to Angular

I'm new to Angular. I'm trying to use xterm.js (https://xtermjs.org/) but it display badly. Here is the render : Render I created a xterm component. The xterm.component.ts file code is : import { Component, OnInit } from '@angular/core'; import {…
Clément Drouin
  • 323
  • 1
  • 4
  • 11
4
votes
2 answers

How do I properly mock a DOM so that I can test a Vue app with Jest that uses Xterm.js?

I have a Vue component that renders an Xterm.js terminal. Terminal.vue