Skip to content
Advertisement

Enabling colors in term.js

I am using term.js for emulating a terminal in the web browser via JavaScript and Node.js.

I have already setup the basic implementation and I can connect to both local as well as remote host (I use node ssh2 to connect to a remote host). Everything works as expected, except that it’s black and white (black background, white text).

I have the following code in the client which is as per the example in the repository. Should I add some extra configuration to enable colors?

JavaScript

Advertisement

Answer

Color works for me. Here’s my test setup on Ubuntu:

Install dependencies first: npm install express socket.io ssh2 term.js

Install the colortest package on the remote server (that you’re ssh’ing into): sudo apt-get install colortest -y

server.js:

JavaScript

public/client.htm:

JavaScript

Execute node server.js and then visit http://localhost:8000/client.htm in your browser. You should see something like this.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement