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 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 likebash
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"
.