jQuery Command Line Interpreter Plugin - Terminal Emulator

jQuery Command Line Interpreter Plugin - Terminal Emulator
File Size: 386 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT

A simple jQuery based terminal emulator that make it easy to create command line interpreter for your website or web application.  Command Line Interpreter is a blanket term for a certain class of programs designed to read lines of text entered by a user, thus implementing a command-line interface.(More info about Command Line Interpreter on WIKI). 

Licensed under GNU LGPL Version 3 license.

You might also like:

Main Features:

  • Automatically call JSON-RPC service.
  • You can provide you own function in which you can parse user command.
  • Command Tree supported
  • Command line history supported
  • Tab completion supported
  • Keyboard shortcut like CTRL+A, CTRL+D, CTRL+E etc, supported
  • Authentication supported
  • Multiple Command Line Interpreters on one page supported


$ npm install jquery.terminal

# Bower
$ bower install jquery.terminal

Basic Usage:

1. Include jQuery library and terminal emulator plugin on your page

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/jquery.terminal-min.js"></script>

2. Include Mouse Wheel Plugin to support mouse wheel feature

<script src="js/jquery.mousewheel-min.js"></script>

3. Include jQuery Terminal Emulator CSS to style the plugin

<link href="css/jquery.terminal.css" rel="stylesheet"/>

4. The Javascript

    jQuery(document).ready(function($) {
        $('body').terminal("json-rpc-service-demo.php", {
            login: true,
            greetings: "You are authenticated",
            onBlur: function() {
                // the height of the body is only 2 lines initialy
                return false;

5. Default options.

prompt: '> ',
history: true,
exit: true,
clear: true,
enabled: true,
historySize: 60,
maskChar: '*',
wrap: true,
checkArity: true,
raw: false,
exceptionHandler: null,
memory: false,
cancelableAjax: true,
processArguments: true,
linksNoReferrer: false,
processRPCResponse: null,
Token: true, // where this came from?
convertLinks: true,
extra: {},
historyState: false,
importHistory: false,
echoCommand: true,
scrollOnEcho: true,
login: null,
outputLimit: -1,
formatters: [],
onAjaxError: null,
scrollBottomOffset: 20,
wordAutocomplete: true,
clickTimeout: 200,
request: $.noop,
response: $.noop,
onRPCError: null,
completion: false,
historyFilter: null,
softPause: false,
onInit: $.noop,
onClear: $.noop,
onBlur: $.noop,
onFocus: $.noop,
onTerminalChange: $.noop,
onExit: $.noop,
onPush: $.noop,
onPop: $.noop,
keypress: $.noop,
keydown: $.noop,
strings: {
  comletionParameters: 'From version 1.0.0 completion function need to' +
      'have two arguments',
  wrongPasswordTryAgain: 'Wrong password try again!',
  wrongPassword: 'Wrong password!',
  ajaxAbortError: 'Error while aborting ajax call!',
  wrongArity: "Wrong number of arguments. Function '%s' expects %s got" +
      ' %s!',
  commandNotFound: "Command '%s' Not Found!",
  oneRPCWithIgnore: 'You can use only one rpc with ignoreSystemDescr' +
      'ibe or rpc without system.describe',
  oneInterpreterFunction: "You can't use more than one function (rpc " +
      'without system.describe or with option ignoreSystemDescribe cou' +
       'nts as one)',
  loginFunctionMissing: "You didn't specify a login function",
  noTokenError: 'Access denied (no token)',
  serverResponse: 'Server responded',
  wrongGreetings: 'Wrong value of greetings parameter',
  notWhileLogin: "You can't call `%s' function while in login",
  loginIsNotAFunction: 'Authenticate must be a function',
  canExitError: "You can't exit from main interpreter",
  invalidCompletion: 'Invalid completion',
  invalidSelector: 'Sorry, but terminal said that "%s" is not valid ' +
  invalidTerminalId: 'Invalid Terminal ID',
  login: 'login',
  password: 'password',
  recursiveCall: 'Recursive call detected, skip'

More Examples:

Change logs:

v1.7.2 (2017-09-17)

  • fix blur when click ouside terminal when element you click is on top of terminal
  • this is terminal instance inside echo function
  • fix localStorage exception and empty line height while creating terminal from data URI
  • refocus when click on terminal (fix for :focus-within)

v1.6.4 (2017-08-31)

  • build

v1.6.3 (2017-08-28)

  • bugfix

v1.6.2 (2017-08-20)

  • fix altGr+key issue

v1.6.1 (2017-08-15)

  • don't call encode in escape_formatting

v1.6.0 (2017-08-11)

  • new API method apply_formatters
  • add UMD (requested by @fazelfarajzade)
  • add new events: onEchoCommand and onAfterRedraw

v1.5.3 (2017-08-01)

  • fix cursor over entity
  • fix space scroll page

v1.5.2 (2017-08-01)

  • keep formatting when cursor is over one
  • fix jumping prompt when it have newlines

v1.5.1 (2017-07-29)

  • fix autofocus with position: fixed
  • fix input method using sogou keyboard on windows
  • fix long line wrapping and click to move cursor with wider characters like Chinese

v1.5.0 (2017-07-10)

  • run fake keypress and keydown created in input when not fired by the browser (android)
  • improve perfomance by calculating char size only on resize and init (issue reported by @artursOs)
  • new cmd delegate method get_position/set_position added to terminal
  • resolve promises returned from intrpreter in jQuery 2.x
  • allow to use newlines in prompt
  • don't rethrow user exception when exceptionHandler is set (mainly for testing that option)
  • add option describe that is a string mapping procs from system.describe procs (default "procs") it can be "result" or "result.procs" if system.describe is normal JSON-RPC method
  • add option to cmd::disable to not blur so it don't hide android keyboard on pause
  • don't enable terminal on init on Android
  • fix next key after CTRL+V that was triggering input event (reported by @artursOs)
  • fix parsing strings
  • don't hide virtual keyboard on Android when called pause()
  • fix input on Firefox with google keyboard (reported by Filip Wieland)
  • disable terminal on resume event in cordova (is the terminal is disabled when no virutal keyboard)
  • fix moving cursor on click (after multiline command) and the height of the cmd plugin
  • fix escape completion (that enabled by default)
  • remove hardcoded DemoService from json-rpc system.describe

v1.4.3 (2017-06-18)

  • don't execute keypress callback when terminal is disabled
  • fix android (input event was not bind)
  • disable keypress when you press CTRL+key and caps-lock is on

v1.4.2 (2017-05-18)

  • fix context menu pasting and pasting images when terminal not in focus

v1.4.1 (2017-05-16)

  • add rel="noopener" to all links
  • remove anonymous function name that was duplicating parameter with the same name

v1.4 (2017-05-10)

  • fix recursive exception when finalize echo function throw exception
  • fix underline animation
  • add paste using context menu
  • fix wordAutocomplete and add completionEscape option
  • improve parsing commands (it now convert "foo"bar'baz' to foobarbaz like bash)
  • fix normalize and substring
  • remove empty formatting in normalize function

v1.3.1 (2017-05-05)

  • fix cols/rows that was causing signature to not show

v1.3.0 (2017-05-04)

  • remove onPop event from main interpreter (with null as next)
  • add args_quotes to parse_/split_ command api utilities
  • mousewheel work without jQuery mousewheel and fix jumps of text
  • paste of images (using echo) in browsers that support clipboard event
  • fix number of rows after adding underline animation
  • fix outputLimit
  • element resizer (as jQuery plugin) that work inside iframe
  • add IntersectionObserver to add resizer and call resize (not all browser support it,
  • polyfill exists)
  • add MutationObserver to detect when terminal is added/removed from DOM and
  • call IntersectionObserver when added
  • fix calculation of cols and rows
  • New API utiltites normalize, substring, unclosed_strings and helper iterate_formatting
  • strings object are not longer saved in variable on terminal creation so you can
  • change it dynamically after terminal is created (use command to change language)
  • when using rpc or object interpreter it will throw exception when there are
  • unclosed strings
  • add default formatter that handle nested formatting

v1.2.0 (2017-04-22)

  • make terminal accessible to screen readers

v1.1.4 (2017-04-18)

  • fix size with css var with underline animation
  • fix minified css (cssnano was removing unused animations)

v1.1.3 (2017-04-16)

  • fix click to change position when command have newlines

v1.1.2 (2017-04-12)

  • from pauseEvents option form cmd plugin - it always execute keyboard events

v1.1.1 (2017-04-09)

  • don't fire keymap when terminal paused
  • fix delete in IE11
  • restore order of keymap/keydown - keydown is executed first

v1.1.0 (2017-04-09)

  • fix delete in IE11
  • fix CMD+V on MacOS chrome
  • add stay option to insert same as in cmd plugin
  • add option pauseEvents - default set to true
  • fix exception when calling purge more then once
  • fix history: false option
  • keymap have priority over keydown so you can overwrite with CTRL+D keymap function
  • Fix list of contributors in package.json and add script that display json list of them

v1.0.15 (2017-03-24)

  • fix echo command when press tab twice and there are more then one completion
  • fix CTRL+D when paused (it now resume the interpreter)
  • focus don't enable terminal when paused (it was hidden by you could enter text)

v1.0.14 (2017-03-15)

  • fix moving of the content on focus/blur when command line at the bottom
  • don't move cursor on click when focusing
  • throw exception about key property polyfill on init of cmd plugin

v1.0.12 (2017-03-12)

  • fix cursor position when click on word completion on Android

v1.0.11 (2017-03-11)

  • fix dead keys logic (for special keys that don't trigger keypress like delete)

v1.0.10 (2017-03-04)

  • fix dead_keys logic (when keypress after special keys like arrows)

v1.0.8 (2017-02-28)

  • fix paste in IE and Edge

v1.0.7 (2017-02-27)

  • fix exec when pause called in onInit
  • fix reverse search
  • fix 3 argument in completion error
  • fix login from hash for async JSON-RPC
  • fix focus(false)/disable in exec from hash
  • fix regression of pasting in MacOS
  • scroll to bottom in insert method
  • remove default extra property from interpreter (all properties are saved in interperter)
  • and make main options extra pass to intepterer not using extra property
  • fix completion when text have spaces (escaped or inside quotes)
  • fix dead keys on MacOSX (testing shortcuts now require keydown and keypress events)

v1.0.6 (2017-02-17)

  • fix AltGr on non US keyboard layouts

v1.0.5 (2017-02-11)

  • fix CTRL+D to delete forward one character
  • don't use user agent sniffing to get scroll element if terminal attached to body
  • fix & on French layout

v1.0.4 (2017-02-09)

  • fix keypress with key polyfill
  • fix CTRL+V in Firefox and IE
  • fix issue in jQuery >= 3.0
  • fix space, backspace, resize and arrows in IE
  • fix middle mouse paste on GNU/Linux
  • fix signature

v1.0.0 (2017-02-06)

  • simplify changing of terminal colors using css variables
  • always export history and import when importHistory option is true
  • add bar and underline cursor animations and a way to enable it with single css variable
  • recalcualate cols and rows on terminal resize (not only window)
  • request/response and onPush/onPop callbacks
  • all callbacks have terminal as `this` (terminal in parameter stay the same)
  • add option softPause to control pause visible option - it don't hide the prompt when set to true
  • add wordAutocomplete option (default true)
  • add complete and before_cursor api methods and use it for autocomplete
  • formatting for command line (you can't type formatting but you can use $.terminal.formatters to
  • format command you're writing)
  • new option formatters for echo (error method by default disable formatters)
  • interpeter and terminal accept extra option that can be use in onPop or onPush
  • add keymap option to cmd, terminal and interpreter where you can add shortcuts
  • clicking on character, in cmd plugin, move cursor to that character
  • BUGS fixed
  • completion function now have two arguments string and callback and terminal is in this
  • removed setInterpreter, parseArguments, splitArguments, parseCommand and splitCommand
  • if you execute keydown event manualy to trigger terminal/cmd shortcuts you need to pass key property with key name
  • see spec/terminalSpec.js file

v0.11.23 (2017-01-08)

  • add scrollBottomOffset option

v0.11.22 (2016-12-10)

  • scroll to bottom of the terminal when option scrollOnEcho is set to false but the terminal is at the bottom, add new api methods is_bottom and scroll_to_bottom.

v0.11.21 (2016-11-29)

  • don't scroll to terminal (using caret plugin) when it's disabled
  • don't convert links to formatting when raw option is true
  • fix getting data from local storage
  • remove spell check and auto capitalize from textarea

v0.11.18 (2016-11-22)

  • fix getting data from local storage
  • remove spell check and auto capitalize from textarea

v0.11.18 (2016-11-19)

  • fix input method

v0.11.17 (2016-11-15)

  • fix echo when line is short and have newlines
  • add global and echo option wrap to disable long line wrapping
  • don't send warning when mime for JSON-RPC is text/json

v0.11.15 (2016-11-12)

  • replace json_stringify with JSON.stringify
  • fix focus on desktop and mobile
  • allow only memory storage with memory option set to true

v0.11.12 (2016-11-05)

  • Add memory option that allow to not use localStorage nor Cookies

v0.11.12 (2016-11-03)

  • Fix focus on mobile

v0.11.11 (2016-10-08)

  • fix do not enable the terminal on click if it's frozen

v0.11.10 (2016-09-29)

  • fix focus on click

v0.11.9 (2016-09-23)

  • fix outputLimit option

v0.11.8 (2016-09-22)

  • add scrollOnEcho option

v0.11.7 (2016-09-18)

  • fix History::last

v0.11.6 (2016-09-16)

  • fix flush new API method $.terminal.last_id
  • fix focus on Android

v0.11.4 (2016-09-11)

  • allow to change completion using option API method

v0.11.3 (2016-09-06)

  • Add echoCommand option

v0.11.2 (2016-09-05)

  • allow to select text using double click

v0.10.11 (2016-06-06)

  • More fixes.

v0.10.10 (2016-06-02)

  • Escape brackets while echo completion strings

v0.10.9 (2016-05-12)

  • fix issue with jQuery Timers when page included another jQuery after initialization

v0.10.7 (2016-05-12)

  • fix if interpreter is an array and have function

v0.10.6 (2016-05-11)

  • Fix exit build in command and make all builtin case sensitive

v0.10.5 (2016-05-06)

  • Prevent infinite loop in terminal::active when no terminal

v0.10.3 (2016-05-03)

  • keepWords option to echo and words parameter in split_equal
  • Fix login for nested intepreters
  • Fix destroy of cmd plugin
  • Fix url regex for formatting
  • Fix saving commands in hash
  • Allow to disable completion in nested interpreter
  • Change position of cursor in reverse history search
  • Fix pasting in Firefox
  • Exec is adding command to history
  • Fix execHash in FireFox
  • Testsing terminal and cmd plugin + call from command line
  • Fix exec for nested login rpc command
  • Fix exec from hash if commands use pause/resume
  • Fix exec for build in commands
  • Fix other various exec from hash issues
  • Fix local logout and login command
  • mousewheel and resize options for interpreter
  • use MIT license
  • onExport and onImport events

v0.9.3 (2015-12-25)

  • Change settings to method
  • Fix process_commands and escape_regex
  • Fix login from hash
  • Fix raw echo
  • Don't print empty string after removing extended commands strings
  • Fix history_state method

v0.9.2 (2015-12-17)

  • Don't change command line history if ctrl key is pressed
  • Fix middle mouse copy on linux
  • fix resize issue

v0.9.1 (2015-12-13)

  • Add freeze and frozen API methods

v0.8.8 (2014-07-11)

  • Fix 2 json rpc bugs

v0.8.7 (2014-03-22)

  • Space after fully completed command

v0.8.6 (2014-03-13)

  • Space after fully completed command

v0.8.5 (2014-03-11)

  • Fix colors regex and names (from css), use case insensitive regex in formatting

v0.8.4 (2014-03-09)

  • Fix redraw lines on import_view, fix calculating rows

v0.8.3 (2014-03-07)

v0.8.2 (2014-02-26)

  • update

v0.8.1 (2014-02-24)

  • update

v0.8.0 (2014-02-24)

  • CTRL+L Clear terminal
  • Shift+Enter insert newline
  • Remove tabcompletion option (now completion can be true, array or function)
  • Add onRPCError callback
  • Interpreter can be an array
  • ignoreSystemDescribe option
  • Handle invalid JSON-RPC
  • CSS style for standalone cmd plugin
  • using CSS3 Animation for blinking if supported
  • Fix [0m
  • Better error handling (all messages are in $.terminal.defaults.strings)
  • Named colors for terminal formatting
  • expose settings and login function
  • more tools in $.terminal
  • paste kill text with CTRL+Y
  • paste text from selection using middle mouse button
  • Fix login, history and exec
  • Disable few things when in login function
  • All Strings are in $.terminal.defaults.strings
  • more functions in $.terminal object

v0.7.12 (2013-12-13)

  • Don't calcualte num of chars when terminal is not visible
  • Add rest property to parseCommand

v0.7.11 (2013-12-13)

  • Fix last history command

v0.7.10 (2013-11-30)

  • Fix reverse search

v0.7.9 (2013-11-29)

  • Don't show version when calling terminal from source file, allow for terminal without interpreter

v0.7.5 (2013-08-13)

  • Fix flush, add option linksNoReferer

v0.7.4 (2013-08-11)

  • Fix interpreter when there is not system.describe in JSON-RPC
  • Add method flush and fix refresh


This awesome jQuery plugin is developed by jcubic. For more Advanced Usages, please check the demo page or visit the official website.