```
_______ ________ __
/ / _ /_ ____________ _/__ ___/______________ _____ / /
__ / / // / // / _ / _/ // / / / _ / _/ / / \/ / _ \/ /
/ / / // / // / ___/ // // / / / ___/ // / / / / /\ / // / /__
\___/____ \\__/____/_/ \__ / /_/____/_//_/_/_/_/_/ \/\__\_\___/
\/ /____/ version 1.23.2
```
http://terminal.jcubic.pl
[](https://www.npmjs.com/package/jquery.terminal)

[](https://travis-ci.org/jcubic/jquery.terminal)
[](https://coveralls.io/github/jcubic/jquery.terminal?branch=master)

[](http://packagequality.com/#?package=jquery.terminal)
[](https://www.jsdelivr.com/package/npm/jquery.terminal)
[](https://github.com/jcubic/jquery.terminal/blob/master/LICENSE)
### Summary
jQuery Terminal Emulator is a plugin for creating command line interpreters in
your applications. It can automatically call JSON-RPC service when a user types
commands or you can provide you own function in which you can parse user
commands. It's ideal if you want to provide additional functionality for power
users. It can also be used to debug your application.
You can use this JavaScript library to create web based terminal on any website.
### Features:
* You can create an interpreter for your JSON-RPC service with one line
of code (just use url as first argument).
* Support for authentication (you can provide functions when users enter
login and password or if you use JSON-RPC it can automatically call
login function on the server and pass token to all functions).
* Stack of interpreters - you can create commands that trigger additional
interpreters (eg. you can use couple of JSON-RPC service and run them
when user type command)
* Command Tree - you can use nested objects. Each command will invoke a
function, if the value is an object it will create a new interpreter and
use the function from that object as commands. You can use as many nested
object/commands as you like. If the value is a string it will create
JSON-RPC service.
* Support for command line history, it uses Local Storage if possible.
* Support for tab completion.
* Includes keyboard shortcut from bash like CTRL+A, CTRL+D, CTRL+E etc.
* Multiply terminals on one page (every terminal can have different
command, it's own authentication function and it's own command history).
* It catches all exceptions and displays error messages in the terminal
(you can see errors in your javascript and php code in terminal if they
are in the interpreter function).
* Using extended commands you can change working of the terminal without
touching the front-end code (using echo method and terminal formatting
like syntax). Read more in
[docs](https::/terminal.jcubic.pl/api_reference.php#extended_commands)
### Installation
Include jQuery library, you can use cdn from http://jquery.com/download/
```html
```
Then include js/jquery.terminal-1.23.2.min.js and css/jquery.terminal-1.23.2.min.css
You can grab the files from CDN:
```html
```
or
```html
```
If you always want latest version, you can grab the files directly from github using rawgit.com (that service grab the files from github and use propert MIME type so you can use it in your page, you can also grab from devel branch):
```html
```
or get it from [unpkg](https://unpkg.com/) without specifying version, it will redirect
to the latest version:
```html
```
**NOTE:** From version 1.0.0 if you want to support old browsers then you'll need to use [key event property polyfill](https://rawgit.com/inexorabletash/polyfill/master/keyboard.js). You can check the support for it on [can I use](https://caniuse.com/#feat=keyboardevent-key).
```html
```
You can also install jQuery Terminal using command line, from [bower repository](https://bower.io/):
```
bower install jquery.terminal
```
or [npm registry](https://www.npmjs.com/):
```
npm install jquery.terminal
```
### Example of usage
This is code that uses low level function, that gives you full control of the commands,
just pass anything that the user types into a function.
```javascript
jQuery(function($, undefined) {
$('#term_demo').terminal(function(command) {
if (command !== '') {
var result = window.eval(command);
if (result != undefined) {
this.echo(String(result));
}
}
}, {
greetings: 'Javascript Interpreter',
name: 'js_demo',
height: 200,
width: 450,
prompt: 'js> '
});
});
```
Here is a higher level call, using an object as an interpreter, By default the terminal will
parse commands that a user types and replace number like strings with real numbers
regex with regexes and process escape characters in double quoted strings.
```javascript
jQuery(function($, undefined) {
$('#term_demo').terminal({
add: function(a, b) {
this.echo(a + b);
},
foo: 'foo.php',
bar: {
sub: function(a, b) {
this.echo(a - b);
}
}
}, {
height: 200,
width: 450,
prompt: 'demo> '
});
});
```
Command foo will execute json-rpc from foo.php file.
You can create JSON-RPC interpreter with authentication in just one line:
```javascript
$('#term_demo').terminal('service.php', {login: true});
```
More examples [here](http://terminal.jcubic.pl/examples.php). You can also check
[full documentation](http://terminal.jcubic.pl/api_reference.php).
### Security
Because of security in version 1.20.0 links with protocols different then ftp or http(s) (it was possible to enter
javascript protocol, that could lead to XSS if author of hte app echo user input and save it in DB) was turn off
by default. To enable it, you need to use `anyLinks: true` option.
In version 1.21.0 executing terminal methods using extendend commands `[[ terminal::clear() ]]` was also disabled
by default because attacker (depending on your application) could execute `terminal::echo` with raw option to enter
any html and execute any javascript. To enable this feature from this version you need to use `invokeMethods: true`
option.
The features are safe to enable, if you don't save user input in DB and don't echo it back to different users
(like with chat application). It's also safe if you escape formatting before you echo stuff.
If you don't save user input in DB but allow to echo back what user types and have enabled `execHash` options,
you may have reflected XSS vulnerability if you enable this features. If you escape formatting this options are
also safe.
### Contributors
If you want to contrubite read [CONTRIBUTING.md](CONTRIBUTING.md) first. Here are project contributors:
| [ Jakub Jankiewicz](http://jcubic.pl/me) [commits](https://github.com/jcubic/jquery.terminal/commits?author=jcubic) | [ Zuo Qiyang](http://zuoqy.com) [commits](https://github.com/jcubic/jquery.terminal/commits?author=kid1412z) | [ Marcel Link](https://github.com/ml1nk) [commits](https://github.com/jcubic/jquery.terminal/commits?author=ml1nk) | [ Sébastien Warin](http://sebastien.warin.fr) [commits](https://github.com/jcubic/jquery.terminal/commits?author=sebastienwarin) | [ Christopher John Ryan](https://github.com/ChrisJohnRyan) [commits](https://github.com/jcubic/jquery.terminal/commits?author=ChrisJohnRyan) | [ Johan](https://github.com/johanjordaan) [commits](https://github.com/jcubic/jquery.terminal/commits?author=johanjordaan) | [ Florian Schäfer](https://github.com/fschaefer) [commits](https://github.com/jcubic/jquery.terminal/commits?author=fschaefer) |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [ David Refoua](http://www.Refoua.me) [commits](https://github.com/jcubic/jquery.terminal/commits?author=DRSDavidSoft) | [ Ishan Ratnapala](https://github.com/IshanRatnapala) [commits](https://github.com/jcubic/jquery.terminal/commits?author=IshanRatnapala) | [ Tomasz Ducin](http://ducin.it) [commits](https://github.com/jcubic/jquery.terminal/commits?author=ducin) | [ Abdelrahman Omran](https://omranic.com) [commits](https://github.com/jcubic/jquery.terminal/commits?author=Omranic) | [ Anton Vasilev](https://github.com/avdes) [commits](https://github.com/jcubic/jquery.terminal/commits?author=avdes) | [ finlob](https://github.com/finlob) [commits](https://github.com/jcubic/jquery.terminal/commits?author=finlob) | [ Hasan](https://github.com/JuanPotato) [commits](https://github.com/jcubic/jquery.terminal/commits?author=JuanPotato) |
| [ Hraban Luyat](https://luyat.com) [commits](https://github.com/jcubic/jquery.terminal/commits?author=hraban) | [ Martin v. Löwis](https://github.com/loewis) [commits](https://github.com/jcubic/jquery.terminal/commits?author=loewis) | [ Mateusz Paprocki](https://github.com/mattpap) [commits](https://github.com/jcubic/jquery.terminal/commits?author=mattpap) | [ exit1](https://github.com/exit1) [commits](https://github.com/jcubic/jquery.terminal/commits?author=exit1) | [ Robert Wikman](https://github.com/rbw) [commits](https://github.com/jcubic/jquery.terminal/commits?author=rbw) | [ Steve Phillips](https://tryingtobeawesome.com/) [commits](https://github.com/jcubic/jquery.terminal/commits?author=elimisteve) | [ Yutong Luo](https://yutongluo.com) [commits](https://github.com/jcubic/jquery.terminal/commits?author=yutongluo) |
| [ coderaiser](http://coderaiser.github.io) [commits](https://github.com/jcubic/jquery.terminal/commits?author=coderaiser) | [ mrkaiser](https://github.com/mrkaiser) [commits](https://github.com/jcubic/jquery.terminal/commits?author=mrkaiser) | [ stereobooster](https://github.com/stereobooster) [commits](https://github.com/jcubic/jquery.terminal/commits?author=stereobooster) | [ Juraj Vitko](https://github.com/youurayy) [commits](https://github.com/jcubic/jquery.terminal/commits?author=youurayy) |
[jQuery Terminal Website](https://github.com/jcubic/jquery.terminal-www) contributors:
| [ Jakub Jankiewicz](http://jcubic.pl/me) [commits](https://github.com/jcubic/jquery.terminal/commits?author=jcubic) | [ Rich Morin](http://www.cfcl.com/rdm) [commits](https://github.com/jcubic/jquery.terminal/commits?author=RichMorin) | [ DInesh51297](https://github.com/DInesh51297) [commits](https://github.com/jcubic/jquery.terminal/commits?author=DInesh51297) | [ Logan Rosen](http://www.loganrosen.com/) [commits](https://github.com/jcubic/jquery.terminal/commits?author=loganrosen) |
| :---: | :---: | :---: | :---: |
### License
Licensed under [MIT](http://opensource.org/licenses/MIT) license
Copyright (c) 2011-2018 [Jakub Jankiewicz](http://jcubic.pl/jakub-jankiewicz)