Minimal Interactive Terminal In JavaScript – Terminal.js

Category: Javascript , Recommended | November 18, 2021
Views Total:103 views
Official Page:Go to website
Last Update:November 18, 2021


Minimal Interactive Terminal In JavaScript – Terminal.js


A super tiny JavaScript library to emulate an interactive terminal on the page.

How to use it:

1. Insert the main script Terminal.js into the document.

<script src="JS/terminal.js"></script>

2. Build the HTML for the terminal emulator.

<div class="terminal_window" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
<div class="fakeMenu">
  <div class="fakeButtons fakeClose"></div>
  <div class="fakeButtons fakeMinimize"></div>
  <div class="fakeButtons fakeZoom"></div>
<div class="fakeScreen">
  <div class="terminal-window primary-bg" onclick="document.getElementById('dummyKeyboard').focus();">
    <div class="terminal-output" id="terminalOutput">
      <div class="terminal-line">
        <span class="help-msg">Type <span class="help">help</span> to see a list of supported
    <div class="terminal-line">
      <span class="success">➜</span>
      <span class="directory">~</span>
      <span class="user-input" id="userInput"></span>
      <span class="line anim-typewriter"></span>
      <input type="text" id="dummyKeyboard" class="dummy-keyboard" />

3. Add your own commands as follows:

const COMMANDS = {
  rd: "Whoa!!! You found the secret command!!! To get access to the beta for my apps, go <a href = '' target = '_blank' style = 'color:#000;'> here </a> <br>The beta code is A3T4M",
  n: "OK",
  no: "OK",
    "This bit is coming soon. In the meantime, Feel free to visit my <a href ='' target='_blank' style='color:#000;'> Github",
  cd: "changed directory to root..",
  "cd ..": "cd: no such file or directory",
  "cd var": "var aliased to ../",
  "cd root": "access denied",
  "cd usr": "no users found",
  "cd home": "home was aliased to .",
  sudo: "user not in the sudoers file.  This incident will be reported.",
    'Supported commands: <span class="code">about</span>, <span class="code">contact</span>, <span class="code">projects</span>, <span class="code">github</span><br>System commands: <span class="code">clear</span>, <span class="code">history</span>, <span class="code">cd</span>, <span class="code">ls</span><br>Tip: Use Up / Down arrow to go through recent commands',
    "<span class='aboutHead'>Name:</span> Aayush<br><span class='aboutHead'>Location:</span> Canada<br><span class='aboutHead'>Favourites:</span><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class='aboutTail'>Os</span>: Arch, MacOs&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class='aboutTail'>Editor</span>: Vim, Nova<br/>&nbsp;&nbsp;&nbsp;&nbsp;<span class='aboutTail'>Version Control</span>: Git<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class='aboutTail'>Tabs or Spaces</span>: Depends usually <i>Tabs</i><br>&nbsp;&nbsp;&nbsp;&nbsp;",
    "Email (coming soon): <a class='link' href=''>Gmail</a><br>Form: <a href='/contact' class='link'> Anon Message</a><br>",

You Might Be Interested In:

Leave a Reply