To create terminal you must pass interpreter function (as first argument) which will be called when you type enter. Function has two argumentss command that user type in terminal and terminal instance. Optionally you can pass string as first argument, in this case interpreter function will be created for you using passed string as URI (path to file) of JSON-RPC service (it's ajax so must be on the same server or use CORS).
toggle highlight$('#some_id').terminal(function(command) {
if (command == 'test') {
this.echo("you just typed 'test'");
} else {
this.echo('unknown command');
}
}, { prompt: '>', name: 'test' });
- $('#some_id').terminal(function(command) {
- if (command == 'test') {
- this.echo("you just typed 'test'");
- } else {
- this.echo('unknown command');
- }
- }, { prompt: '>', name: 'test' });
-
You can pass object as first argument - the methods will be invoked by commands typed by a user. In those methods this will point to terminal object.
toggle highlight$('#some_id').terminal({
echo: function(arg1) {
this.echo(arg1);
},
rpc: 'some_file.php',
calc: {
add: function(a, b) {
this.echo(a+b);
},
sub: function(a, b) {
this.echo(a-b);
}
}
}, { prompt: '>', greeting: false });
- $('#some_id').terminal({
- echo: function(arg1) {
- this.echo(arg1);
- },
- rpc: 'some_file.php',
- calc: {
- add: function(a, b) {
- this.echo(a+b);
- },
- sub: function(a, b) {
- this.echo(a-b);
- }
- }
- }, { prompt: '>', greeting: false });
-
This code will create two command echo that will print first argument and add that will add two integers.
From version 0.8.0 you can also use array with strings, objects and functions. You can use multiple number of objects and strings and one function (that will be called last if no other commands found). If you have ignoreSystemDescribe function enabled you will be able to use only one string (JSON-RPC url). If you have completion enabled then your commands will be that from objects and JSON-RPC that have system.describe
toggle highlight$('#some_id').terminal(["rpc.php", {
"mysql": function() {
this.push(function(command, term) {
$.jrpc("rpc.php", 'mysql', [command], function(json) {
term.echo(json.result);
});
}, {
prompt: 'mysql> '
}
);
}
}], {
prompt: '>',
greeting: false
});
- $('#some_id').terminal(["rpc.php", {
- "mysql": function() {
- this.push(function(command, term) {
- $.jrpc("rpc.php", 'mysql', [command], function(json) {
- term.echo(json.result);
- });
- }, {
- prompt: 'mysql> '
- }
- );
- }
- }], {
- prompt: '>',
- greeting: false
- });
-
In previous example mysql will be exception, even that rpc have that method it will not call it but create new interpreter.
Terminal will always process numbers if processArguments is set to true (by default).
To have automatic json-rpc service the JSON-RPC endpoint should implement system.describe method, bby default it need to be json object with "procs" property that should be array of that should look like this (params array is optional):
toggle highlight{
"procs": [
{"name": "foo", "params": ["a", "b"]},
{"name": "bar", "params": ["a"]}
]
}
- {
- "procs": [
- {"name": "foo", "params": ["a", "b"]},
- {"name": "bar", "params": ["a"]}
- ]
- }
If your system.describe method can't return that object you can use describe options, you can use `"result.procs"` and return normal JSON-RPC response with object that have procs property with the same array.
This is a list of options (for second argument):
- anyLinks boolean — enable to enter links other then ftp or http(s) in echo (add in version 1.20.0 because of security, an attacker could use javascript protocol - XSS) default set to false. See security.
- checkArity [bool] — if set to true (by default) it will check the number of arguments in functions and in JSON-RPC if service return system.describe (only 1.1 draft say that it must return it, new Spec 2.0 don't say anything about it, json-rpc used by examples return system.describe).
- clear [bool] — if this option is set to false, it does not include the “clear” command, default is true.
- clickTimeout [number] — timeout to detect double click, if second click is faster then the timeout it is considered as double click. Default 200 milisecond.
- completion [function (string, callback)|array|boolean] — function with a callback that needs to be executed with a list of commands for tab completion (you need to pass an array of commands to the callback function), from version 0.8.0 you can also use true (it will take completion from object or RPC, if it has system.describe, as an interpreter) or an array if you know what your commands are and don't need to call ajax to get them. From version 1.0.0 it no longer uses terminal as a parameter, terminal is now in
this
context. - convertLinks [boolean] — if set to true it will convert urls to tags, it does that by default.
- describe [string|false] — it should be a dot-separated string that points to files that have a list of procedures, if you have a normal JSON-RPC method, you can use "result" or "result.procs." It can also be an empty string, in which case the response will be taken as an array of procedures. If the value is set to false it will not call system.describe method, same as ignoreSystemDescribe == true.
- doubleTab [function|boolean] — the function is executed if you press the tab twice and there is more than one completion. The function has three arguments: completing string, an array of completions, and an echo_command function. If you pass false, it will disable the double tab.
- echoCommand [boolean] — if set to false terminal will not echo command you enter with prompt, default true.
- enabled [bool] — default is true, if you want to disable terminal you can set it to false. This is useful if you want to hide the terminal and enable it on some actions (If the terminal is enabled, it intercepts the keyboard).
- exceptionHandler [function(exception)] — callback that will be executed instead of default print exception on terminal.
- execHash [boolean] — if set to true it will execute commands from url hash, the hash needs to have a form of JSON array that looks like this
#[[0,1,"command"],[0,2,"command2"]]
first number is index of terminal on a page second is index of command for terminal. (0 is initial state of the terminal so first command have index of 1). Set to false by default. You can record commands you type by calling history_state method. - exit [bool] — if this option is set to false, do not use CTRL+D to exit from the terminal and don't include the “exit” command, default is true.
- greetings [string|function(callback)] — default is set to JQuery Terminal Signature. You can set it to string or function (like prompt) with callback argument which must be called with your string.
- history [bool] — if false will not store your commands.
- historyFilter [function(command)] — if you return false in this function command will not be added into history.
- historySize [number] — size of the history (default 60) if you pass falsy value it will be not restricted.
- historyState [boolean] — if set to true, the terminal will record all commands in url hash.
ignoreSystemDescribe [boolean] — if used it will not call system.describe metod for JSON-RPC (it was in version 1.1 of JSON-RPC which was a draft, but it's supported by JSON-RPC implementetion used in demos). in version 1.5 replaced with describe option- importHistory [boolean] — if the options is to true it will import history in import_view and export by export_view, default set to false.
- invokeMethods boolean — enable using terminal and cmd methods in extended commands of echo, default is false because of security (an attacker could invoke echo with raw option). See security.
- keydown [function(event, terminal)] — when a function is called on keydown event, it will not execute default actions if false. (keydown event is used for the shortcuts).
- keymap — object where keys are uppercase shortcuts like CTRL+ALT+C and the value is the function executed on that shortcut. The order of modifiers are CTRL, META, SHIFT, ALT. Added in version 1.0.0.
- keypress [function(event, terminal)] — when a function is called on keypress event, it will not execute default actions if false.(keypress event is called when you type printable characters).
- linksNoReferer [bool] — if set to true, it will add rel="noreferer" to all links created by the terminal (default is false).
- linksNoReferrer [boolean] — if set to true, it will set noreferrer on links, default set to false.
- login [function(user, password, callback)|string] — login can be a function, string or boolean. A function must have 3 arguments: login, password and callback which must be called with a token (if login and password match) or falsy value (if authentication fail). If the interpreter is a string with valid URI JSON-RPC service, you can set the login option to true (it will use login remote method) or name of RPC method. this in login function is a terminal object.
toggle highlightfunction(user, password, callback) {
if (user == 'demo' && password == 'secret') {
callback('AUTHENTICATION TOKEN');
} else {
callback(null);
}
}
- function(user, password, callback) {
- if (user == 'demo' && password == 'secret') {
- callback('AUTHENTICATION TOKEN');
- } else {
- callback(null);
- }
- }
But you need to know that everybody can look at your javascript source code so it's better to call server using AJAX here and call callback on response. If callback receives truthy value, you can get that value using token method so you can pass when calling the server (and server then can identify that token).
- maskChar [boolean|string] — the default mask character is `*' (if set to true). It is used when you use
set_mask(true)
. - memory [bool] — if set to true it will not use localStorage nor Cookies and save everything in memory only, default false.
- mobileDelete [bool] — default is true if used on mobile device. False on desktop (If set to true, it will delete a character when you hold a key that should delete the character, e.g., the delete or backspace key.).
- name [string] — name is used if you want to distinguish between two or more terminals on one page or on one server. (if you name them differently they will have different history and authentication).
- numChars/numRows [number] — fixed number of rows and cols, created mainly for testing from node.
- onAfterCommand [function(command)] — callback function executed after the command.
- onAfterLogout [function] — function executed after logout from the terminal if there was a login.
- onAjaxError [function(xhr, status, error)] — function executed on JSON-RPC ajax error. (this in this function is terminal object).
- onBeforeCommand [function(command)] — function executed before command. If the function returns false, the command will not be executed.
- onBeforeLogin [function(terminal)] — callback function called before login.
- onBeforeLogout [function] — function executed before logout from main interpreter. If the function returns false, the terminal will not logout.
- onBlur [function(terminal)] — callback function called when the terminal gets out of focus. If you return false in this callback function the terminal will not get out of focus.
- onClear [function(terminal)] — callback function called when clear command is executed.
- onCommandChange [function(command, terminal)] — event fired when command line is changed.
- onCommandNotFound [function(command, terminal)] — function is executed if there are no commands with that name, by default terminal display error message, it will not work if you use function as an interpreter.
- onExit [function(terminal)] — callback function called when you logout.
- onExport/onImport [function] — callback functions executed when calling export/import. You can add properties additional state to be saved and restored. in export you need to return object which properties will be added to export object and on import you get imported object as argument. It's used in leash to save/restore current working directory and directory listing for completion.
- onFocus [function(terminal)] — callback function called when the terminal gets focus.
- onInit [function(terminal)] — callback function called after initialization (if there is login function it will be called after authentication).
- onPause [function] — function executed when you call pause() or return a promise from a command.
- onPop [function] — function is executed each time pop is called, CTRL+D also calls pop so the function is triggered, this method is also executed when you have login and you exit from the main interpreter.
- onPush [function] — function executed when you push new interpreter on to the stack of interpreters.
- onRPCError [function(error)] — callback function that will be called instead of built in RPC error. (this in that function is terminal object).
- onResize [function(terminal)] — callback function called when the terminal gets resized.
- onResume [function] — function executed when you call resume() or when promise returned in command is resolved.
- onTerminalChange [function(terminal)] — callback function called when you switch to the next terminal.
- outputLimit [number] — if non-negative, it will limit the printing lines on the terminal. If set to 0, it will print only lines that fit on one page (it will not create scrollbar if it's enabled). The default is -1 which will disable the function.
- pauseEvents [boolean] — if set to false keypress, keydown and keymap will be executed when the terminal is paused. Default set to true.
- processArguments [bool | function] — if set to true, it will process arguments when using an object (replace regex with real regex object number with numbers and process escape characters in double quoted strings - like \x1b \033 will be Escape for ANSI codes) - default true. If you pass a function you can parse the command line by yourself - it will have one argument with string without name of the function and you need to return an array.
- processRPCResponse [function(object)] — callback function that will be used with any result returned by JSON-RPC. So you can create a better handler.
- prompt [string|function] — default is “> ” you can set it to string or function with one parameter which is callback that must be called with string for your prompt (you can use ajax call to get prompt from the server). You can use the same formatting as in echo.
- request [function(jxhr, terminal, request)] — callback function called before sending JSON-RPC request to the server (it's also called on system.describe), you can modify request or jQuery XHR object, see CSRF Example. Added in version 1.0.0.
- response [function(jxhr, terminal, response)] — callback function called after JSON-RPC response (it's also called on system.describe), you can modify response before it's processed by the jQuery Terminal, also you can call methods on jQuery XHR object. see CSRF Example. Added in version 1.0.0.
- scrollBottomOffset number — indicate offset from bottom in which terminal will consider at bottom of the terminal. Used in
is_bottom
method. - scrollOnEcho [boolean] — indicates if the terminal should scroll to the bottom on echo or flush. If set to false, it will scroll to the bottom if the terminal was at the bottom, it uses the
is_bottom
method. - softPause [boolean] — if set to true it will not hide command line when paused, useful if you want to have progress animation using prompt. Default set to false.
tabcompletion [bool] — enable tab completion when you pass object as first argument. Default is false (tabulation key default insert tabulation character). removed in version 0.8.0.- wordAutocomplete [boolean] — if set to false it will autocomplete whole command before cursor, default set to true to autocomplete only word.
- wrap [boolean] — if set to false the terminal will not wrap long lines (it can be overwritten by the echo option), the default is true
system.describe JSON-RPC method
As per JSON-RPC 1.1 the method should return this json:
toggle highlight{
"sdversion": "1.0",
"name": "DemoService",
"address": "http:\/\/example.com\/rpc",
"id":"urn:md5:4e39d82b5acc6b5cc1e7a41b091f6590",
"procs" :[
{"name":"echo","params":["string"]}
]
}
- {
- "sdversion": "1.0",
- "name": "DemoService",
- "address": "http:\/\/example.com\/rpc",
- "id":"urn:md5:4e39d82b5acc6b5cc1e7a41b091f6590",
- "procs" :[
- {"name":"echo","params":["string"]}
- ]
- }
Before version 1.5 it was required to have a name == 'DemoService' which was added by mistake, fixed in 1.5. Before version 1.5 it was also required to have a name and an id.
In version >= 1.5 you can use option describe to point to the different fields instead of procs (you can use result.procs
and standard JSON-RPC response).
You will have access to terminal object in this object when you put object as first argument. In second argument if you put a function. That object is also returned by the plugin itself. The terminal is created only once so you can call that plugin multiple times. The terminal object is jQuery object extended by methods listed below.
If you want to get instance of the terminal object when you already have terminal created you can call $('selector').terminal()
.
This is list of available methods (you can also use jQuery methods):
- autologin([username, token]) — autologin if you get username and token in other way, like in sysend event.
- before_cursor([boolean]) — get string before cursor if the only argument is true it will return word otherwise it will return whole text.
- clear() — clear terminal.
- clear_buffer() — clear the buffer (filled with
echo(..., { flush:false})
). - clear_history_state() — clear saved history state.
- cols()/rows() — returns number of characters and number of lines of the terminal.
- complete([array, options]) — automplete text based on array, usefull if custom autocomplete need to be implemended, see autocomplete example. There are two options word — to indicate of completion should be for whole command or only a word before cursor (default true) and echo that indicate if it should echo matched commands if more then one found (default false).
- destroy() — remove everything created by terminal. It will not touch local storage, if you want to remove it as weel use purge.
- display_position([number], [boolean]) — move virtual cursor to specied position or relative to curent position if second argument is true. Works only if you have formatter that change length.
- echo([string|function], [options]) — display string on terminal — (additionally if you can call this function with a function as argument it will call that function and print the result, this function will be called every time you resize the terminal or browser).
There are five options:
- raw — it will allow to display raw html,
- finalize — which is callback function with one argument the div container,
- flush — default is true, if it's false it will not print echo text to terminal until you call flush method,
- wrap — default is undefined, if set to true or false it will overwritten global option,
- keepWords — it will not break text in the middle of the word (available from version 0.10.0).
- newline — default true, if set to false it will not print newline, it require including of echo_newline.js file.
You can also use basic text formatting using syntax as folow: [[!guib;<COLOR>;<BACKGROUND>]some text] will display some text:
- [[ — open formatting.
- u — underline.
- s — strike.
- o — overline.
- i — italic.
- b — bold.
- g — glow (using css text-shadow).
- ! — it will create link instead of span,
you need to turn off convertLinks option for this to work. from version 1.20.0 links other then ftp or http(s) was disabled by default and it enable it you need to use anyLinks: true
option.
- @ — it will create an image instead of span. Added in 2.8.0. It's also supported in less.
- ; — separator
- color — color of text (hex, short hex or html/css name of the color).
- ; — separator.
- color — background color (hex, short hex or html/css name of the color).
- ; — separator [optional].
- class — class adeed to format span element [optional].
- ; — separator [optional].
- text — text that will be used in data-text attribute, href if used with ! or src when used with @. This is added automatically by normalize called in split_equal.
- ; — separator [optional].
- attribies — JSON object for the attributes, the properties are limited to those defined in $.terminal.defaults.allowedAttributes array that can contain string or regular expressions. By default the array is defined as ["title", /^aria-/, "id", /^data-/], the list may change in the future, don't depend on those properties. You can use this feature for instance to add inline styles.
- ] — end of format specification.
- text — text that will be formated. If @ is used it will alt atttribute
- ] — end of formatting.
From version 1.3.0 (with fix in 1.10.0) you can use nested formatting like [[;red;]foo [[;blue;]bar] baz]
(terminal is defining $.terminal.nested_formatting
and adding it to $.terminal.defaults.formatters
).
From version 0.4.19 terminal support ANSI formatting like \x1b[1;31mhello[0m will produce red color hello. Here is shorter description of ansi escape codes.
From version 0.7.3 it also support Xterm 8bit (256) colors (you can test using this GNU Head) and formatting output from man command (overtyping).
From version 0.8.0 it support html/css colors like blue, navy or red
From version 0.9.0 Ansi escape code require unix_formatting.js file.
From version 0.9.0 you can execute commands using echo (you can return command to be executed from server) using same syntax as for formatting, if you echo: [[command arg1 arg2...]]
it will execute that command.
From version 1.15.0 you can execute any terminal or cmd method using systax [[ terminal::method(arg1, arg2) ]]
or [[ cmd::method(arg1, arg2) ]]
, in older version you'll need to create command that will invoke terminal method. You can use new in version 1.15.0 method invoke_key
to execute shortcuts from server using [[ terminal::invoke_key("CTRL+L") ]]
.
If you want to create code that manipulate terminal formatting take a look at $.terminal.formatter object.
From version 1.21.0 executing terminal and cmd methods was disabled by default (because of security) and to enable it you need to use invokeMethods: true
option.
Details about formatting can be found on GitHub Wiki pages: Formatting and Syntax Highlighting and Invoking Commands and terminal methods from Server.
- enable()/disable() — as names says it enable or disable terminal.
- error([string|function]) — it display string in in red.
- exception(Error, [Label]) — display exception with stack trace on terminal (second paramter is optional is used by terminal to show who throw the exception).
- exec([string, bool]) — Execute command that like you where type it into terminal (it will execute user defined function). Second argument is optional if set to true, it will not display prompt and command that you execute. If you want to have proper timing of executed function when commands are asynchronous (use ajax) then you need to call pause and resume (make sure that you call pause before ajax call and resume as last in ajax response).
- export_view() — return object that can be use to restore the view using import_view.
- flush() — if you echo using option
flush: false
(it will not display text immediately only add the thing into a buffer) then you can send that text to the terminal output using this function. - focus([bool]) — it will activate next terminal if argument is false or disable previous terminal and activate current one. If you have only one terminal instance it act the same as disable/enable.
- freeze([boolean])/frozen() — freeze: disable/enable terminal that can't be enabled by clicking on terminal, frozen check if terminal has been frozen by freeze command.
- get_command() — return current command.
- get_output([boolean]) — return string contains whatever was print on terminal, if argument is set to true it will return raw lines data.
- get_output_buffer() — function return output buffer processed by the terminal, when using
echo(..., { flush:false})
. - get_prompt() — return current prompt.
- get_token([boolean]) — same as token().
- history() — return command line History object (need documentation - for now you can check the source code)
- history_state([boolean]) — disable or enable history sate save in hash. You can create commads that will start or stop the recording of commands, the commands itself will not be recorded.
- import_view([view]) — restore the view of the terminal using object returned prevoiusly by export_view.
- insert(string) — insert text in cursor position.
- invoke_key([string]) — invoke shortcut,
terminal.invoke_key('CTRL+L')
will clear terminal. - is_bottom() — return true if terminal scroll is at the bottom. It use scrollBottomOffset option to calculate how much from bottom it will consider at bottom.
- last_index() — return index of last line that can be use with update method after you echo something and you lost the reference using -1.
- level() — return how deeply nested in interpreters you correctly in (It start from 1).
- login([function(user, password, callback), boolean]) — execute login function the same as login option but first argument need to be a function. The function will be called with 3 arguments, user, password and a function that need to be called with truthy value that will be stored as token. Each interpreter can have it's own login function (you will need call push function and then login. The token will be stored localy, you can get it passing true to token function. Second argument indicate if terminal should ask for login and password infinitely.
- login_name() — return login name which was use in authentication. This is set to null if there is no login option.
- logout() — if you use authentication it will logout from terminal. If you don't set login option this function will throw exception.
- name() — return name of the interpreter.
- next() — if you have more then one terminal instance it will switch to next terminal (in order of creation) and return reference to that terminal.
- pause([boolean])/resume() — if your command will take some time to compute (like in AJAX call) you can pause terminal (terminal will be disable and command line will be hidden) and resume it in AJAX response is called. (if you want proper timing when call exec on array of commands you need to use those functions). From version 0.11.1 pause accept optional boolean argument that indicate if command line should be visible (this can be used with animation).
- paused() — return true if terminal is paused.
- pop() — remove current interpreter from the stack and run previous one.
- prefix_name([boolean]) — return name that is used for localStorage keys, if argument is true it will return name of local interpreter (added by push() method).
- purge() — remove all local storage left by terminal. It will act like logout because it will remove login and token from local storage but you will not be logout until you refresh the page.
- push([string|function], {object}) — push next interpreter on the stack and call that interpreter. First argument is new interpreter (the same as first argument to terminal). The second argument is a list of options as folow:
- name — to distinguish interpreters using command line history.
- prompt — new prompt for this terminal.
- onExit — callback function called on Exit.
- onStart — callback function called on Start.
- keydown — interpreter keydown event.
historyFilter — the same as in terminal in next version.
- completion — the same as in terminal.
- login — same as login main option or calling login method after push.
- keymap — same as keymap in terminal.
- mousewheel — interpreter based mousewheel handler.
- infiniteLogin — if set to true it will ask infinetly for username and password if login is set.
Additionally everything that is passed within the object will be stored with interpreter on the stack — so it can be pop later. See also Multiple intepreters example.
- read([string, success_fn, cancel_fn]) — wrapper over push, it set prompt to string and wait for text from user then call user function with entered string. The function also return a promise that can be used interchangeably with callback functions. from version 1.16.0 read disable history.
- reset() — reinitialize the terminal.
- resize([number, number] — change size of terminal if is called with two arguments (width,height) it will resize using this values. If is called without arguments it will act like refresh and use current size of element (you can use this if you set size in some other way).
- save_state([command, boolean]) — it save current state of the terminal and update the hash. If second argument is true it will not update hash.
- scroll([number]) — you can use this method to scroll manually terminal (you can pass positive or negative value).
- scroll_to_bottom() — as the name suggest is scroll to the bottom of the terminal.
- set_command(string) — set command using string.
- set_interpreter([interpreter, login]) — overwrite current interpreter.
- set_mask([bool|string]) — toogle mask of command line if argument is true it will use maskChar as mask.
- set_prompt([string|function(callback)]) — change the prompt.
- set_prompt([string|function]) — set prompt.
- set_token([string, boolean]) — update token.
- settings() — return reference to settings object that can change options dynamicaly. Note that not all options can be change that way, like history based options.
- signature() — return JQuery Singature depending on size of terminal.
- token([boolean]) — return token which was set in authentication process or by calling login function. This is set to null if there is no login option. If you pass true as an argument you will have local token for the interpreter (created using push function) it will return null if that interpreter don't have token.
- update(line, string) — update line with specified number with given string. The line number can be negative (-1 will change last line) the lines are indexed from 0.
Object $.terminal contain bunch of utilities use by terminal, but they can also be used by user code.
- active() — return selected terminal.
- ansi_colors — object contain 4 objects normal, fainted, bold and pallete (8bit colors) that contains hex colors for ansi formatting (taken from linux terminal emulator), NOTE: from version 0.9.0 provided by unix_formatting.js file.
- defaults — contain all default options used by terminal plugin. All strings are in defaults.strings and can be translated.
- encode([string]) — encode &, new line, space, tabs, < and > with entities.
- escape_brackets([string]) — replace [ and ] with number entities.
- escape_regex([string]) — covert string that can be use in regex (RegExp constructor) literally.
- format([string, object] — create html <span> elements from terminal formattings. Second argument are options with one option linksNoReferrer.
- format_split([string]) — return array of formatting and text between them.
- from_ansi([string]) — convert ANSI encoding to terminal encoding. If used with format it will produce html from ANSI encoding. NOTE: from version 0.9.0 provided by unix_formatting.js file.
- have_formatting([string]) — test if string have terminal formatting inside.
- is_formatting([string]) — test it string is full formatting (contain only one formatted text and nothing else).
- iterate_formatting([string, callback(data)]) — helper function used in substring and split_equal that iterate over string and execute callback when in text with object:
- count: number of characters in text (it skip brackets and formatting)
- index: character index (including brackets and formatting)
- formatting: string containing current formatting if itration is in formatting or empyt string if not
- space: index of last space
Function added in 1.3.0
- last_id() — return id of the last terminal. If you add 1 to that number it will be id of the next terminal.
- normalize([string]) — function that add extra last item in formatting if not present (added in 1.3.0) .
- overtyping([string]) — convert string containing formatting from man command (overtyping) to terminal formatting. If used with format it will produce html from man. NOTE: from version 0.9.0 provided by unix_formatting.js file.
- palette — array of 8bit XTerm colors. NOTE: from version 0.9.0 provided by unix_formatting.js file.
- parse_arguments([string]) — return array from command line string. It process number (integer and floats) and regexes, it also convert escaped \x \0 to real characters when inside double quote. It remove enclosing quotes from strings.
- parse_command([string]) — return object with keys: name, args and rest that contain name of the command, it's arguments and string without command name. It use parse_arguments function.
- parse_options([array|string], object) — function will parse options and return an object like yargs parser. For each single option like -a create a field with true or value after the option (-af foo will create
a: true, f: "foo"
, if f is in boolean option array it will put f: true
and foo will be in "_"), _ field will contain all non options, and log options (like --file at the begining) will be into object like file: "foo.js"
).
Examples:
toggle highlight$.terminal.parse_options("--foo bar -abc baz quux");
// {_: ["quux"], a: true, b: true, c: "baz", foo: "bar"}
var cmd = $.terminal.split_command("copy --foo bar -abc baz quux");
$.terminal.parse_options(cmd.args, {boolean: ["foo", "c"]});
// all options will be boolean and they arguments will be counted as free arguments
// {_: ["bar", "baz", "quux"], a: true, b: true, c: true, foo: true}
$('body').terminal({
copy: function(...args) {
var options = $.terminal.parse_options(args);
if (options.dest && options.src) {
if (copy(options.src, options.dest)) {
this.echo('[[;darkgreen;]successful]');
} else {
this.error('failed');
}
} else {
this.echo('usage\ncopy --dest <file> --src <file>');
}
}
}, {checkArity: false});
function copy(src, dest) {
if (src === 'nonexistent') {
return false;
}
return true;
// NOTE: for this dummy example, you can use
// return src !== 'nonexistent';
}
- $.terminal.parse_options("--foo bar -abc baz quux");
-
- var cmd = $.terminal.split_command("copy --foo bar -abc baz quux");
- $.terminal.parse_options(cmd.args, {boolean: ["foo", "c"]});
-
- $('body').terminal({
- copy: function(...args) {
- var options = $.terminal.parse_options(args);
- if (options.dest && options.src) {
- if (copy(options.src, options.dest)) {
- this.echo('[[;darkgreen;]successful]');
- } else {
- this.error('failed');
- }
- } else {
- this.echo('usage\ncopy --dest <file> --src <file>');
- }
- }
- }, {checkArity: false});
-
- function copy(src, dest) {
- if (src === 'nonexistent') {
- return false;
- }
- return true;
-
-
- }
- split_arguments([string]) — similar to parse_arguments but convert only escape space to space and remove enclosing quotes from strings.
- split_command([string]) — similar to parse_command but use split_arguments.
- split_equal([string], [number]) — return array. It split text into equal length lines and keep terminal formatting in place for displaying each line separately.
- strip([string]) — remove formatting from text.
- substring([string, start_index, end_index]) — return subset of the string keeping formatting, end_index is optional (added in 1.3.0) .
- tracking_replace(string, regex, replacement, position) — Function work the same as normal replace but keep track of position change so you can use it in formatter, it return the same output as required by formatters in version >=1.19.0.
- unclosed_strings([string]) — return true if string have unclosed strings, it's used when parsing command for internal use (rpc or object interpreter) if return true it will throw exception (added in 1.3.0).
Command Line is created as separate plugin, so you can create instance of it (if you don't want whole terminal):
toggle highlight$('#some_id').cmd({
prompt: '$> ',
width: '100%',
commands: function(command) {
//process user commands
}
});
- $('#some_id').cmd({
- prompt: '$> ',
- width: '100%',
- commands: function(command) {
-
- }
- });
Here is demo that creates terminal using only cmd.
And this pen is a demo of creating text based dialog.
Command Line options: name, keypress, keydown, mask, enabled, width, prompt, commands, keymap.
This is a list of methods if you are what to use only command line.
- name([string]) — if you pass string it will set name of the command line (name is use for tracking command line history) or if you call without argument it will return name.
- history() — returns instance of history object.
- set(string, [bool]) — set command line (optional parameter is is set to true will not change cursor position).
- insert(string, [bool]) — insert string to command line in place of the cursor if second argument is set to true it will not change position of the cursor.
- get() — return current command.
- commands([function]) — set or get function that will be called when user hit enter.
- destroy() — remove plugin.
- prompt([string|function]) — set prompt to function or string — if called without argument it will return current prompt.
- position([number]) — set or get position of the cursor.
- resize([number]) — set numbers of characters — if called with number it will set number of character if call without argument it will recalculate the number of characters depending on actual size.
- enable/disable/isenabled — guess what they do.
- mask([string]) — if argument is true it will mask all typed characters with provided string. If called without argument it will return current mask.
This is list of keyboard shortcuts (mostly taken from bash):
- TAB — tab completion is available or tab character.
- Shift+Enter — insert new line.
- Up Arrow/CTRL+P — show previous command from history.
- Down Arrow/CTRL+N — show next command from history.
- CTRL+R — Reverse Search through command line history.
- CTRL+G — Cancel Reverse Search.
- CTRL+L — Clear terminal.
- CTRL+Y — Paste text from kill area.
- Delete/backspace — remove one character from right/left to the cursor.
- Left Arrow/CTRL+B — move left.
- CTRL+TAB — swich to next terminal (use scrolling with animation) — don't work in Chrome.
- Right Arrow/CTRL+F — move right.
- CTRL+Left Arrow — move one word to the left.
- CTRL+Right Arrow — move one word to the right.
- CTRL+A/Home — move to beginning of the line.
- CTRL+E/End — move to end of the line.
- CTRL+K — remove the text after the cursor and save it in kill area.
- CTRL+U — remove the text before the cursor and save it in kill area.
- CTRL+V/SHIFT+Insert — insert text from system clipboard.
- CTRL+W — remove text to the begining of the word (don't work in Chrome).
- CTRL+H — remove text to the end of the line.
- ALT+D — remove one word after the cursor — don't work in IE.
- PAGE UP — scroll up — don't work in Chrome.
- PAGE DOWN — stroll down — don't work in Chrome.
- CTRL+D — run previous interpreter from the stack or call logout (if terminal is using authentication and current interpreter is the first one). It also cancel all ajax call, if terminal is paused, and resume it.
Additional terminal controls
All interpreters have attached mousewheel event so you can stroll them using mouse. To swich between terminals you can just click on terminal that you want to activate (you can also use focus method).
On Unix, If you select text using mouse you can paste it using middle mouse button (from version 0.8.0).
To change color of terminal simply modify "jquery.terminal.css" file it's really short and not complicated, but you should set inverted class background-color to be the same as color of text.
To change color of one line you can call css jquery method in finalize function passed to echo function.
toggle highlightterminal.echo("hello blue", {
finalize: function(div) {
div.css("color", "blue");
}
});
- terminal.echo("hello blue", {
- finalize: function(div) {
- div.css("color", "blue");
- }
- });
You can also use formatting using echo function. To change whole terminal colors see style section.
You can also use css variables (aka custom properties) to change colors of the whole terminal see style section.
All strings used by the plugin are located in $.terminal.defaults.strings
object, so you can translate them and have i18n.
All exceptions in user functions (interpreter, prompt, and greetings) are catch and proper error is displayed on terminal (with stack trace). If you want to handle exceptions differently you can add exceptionHandler option and create different logic, for instance send exceptions to server or show just exception name without stack trace.
From version 0.8.0 blinking cursor is created using CSS3 animations (if available) so you can change that animation anyway you like, just look at jquery.terminal.css file. If browser don't support CSS3 animation blinking is created using JavaScript.
To change color of the cursor to green and backgroud to white you can use this css:
toggle highlight.terminal, .cmd {
background: white;
color: #0f0;
}
.terminal .inverted, .cmd .inverted, .cmd .cursor.blink {
background-color: #0f0;
color: white;
}
@-webkit-keyframes terminal-blink {
0%, 100% {
background-color: #fff;
color: #0f0;
}
50% {
background-color: #0e0;
color: #fff;
}
}
@-ms-keyframes terminal-blink {
0%, 100% {
background-color: #fff;
color: #0f0;
}
50% {
background-color: #0e0;
color: #fff;
}
}
@-moz-keyframes terminal-blink {
0%, 100% {
background-color: #fff;
color: #0f0;
}
50% {
background-color: #0e0;
color: #fff;
}
}
@keyframes terminal-blink {
0%, 100% {
background-color: #fff;
color: #0f0;
}
50% {
background-color: #0e0;
color: #fff;
}
}
- .terminal, .cmd {
- background: white;
- color: #0f0;
- }
- .terminal .inverted, .cmd .inverted, .cmd .cursor.blink {
- background-color: #0f0;
- color: white;
- }
- @-webkit-keyframes terminal-blink {
- 0%, 100% {
- background-color: #fff;
- color: #0f0;
- }
- 50% {
- background-color: #0e0;
- color: #fff;
- }
- }
-
- @-ms-keyframes terminal-blink {
- 0%, 100% {
- background-color: #fff;
- color: #0f0;
- }
- 50% {
- background-color: #0e0;
- color: #fff;
- }
- }
-
- @-moz-keyframes terminal-blink {
- 0%, 100% {
- background-color: #fff;
- color: #0f0;
- }
- 50% {
- background-color: #0e0;
- color: #fff;
- }
- }
- @keyframes terminal-blink {
- 0%, 100% {
- background-color: #fff;
- color: #0f0;
- }
- 50% {
- background-color: #0e0;
- color: #fff;
- }
- }
From version 1.0.0 you can use css variables with code like this:
toggle highlight.terminal {
--color: rgba(0, 128, 0, 0.99);
--background: white;
}
- .terminal {
- --color: rgba(0, 128, 0, 0.99);
- --background: white;
- }
If you want to have consistent selection you should use rgba color with 0.99 transparency, see this stackoverflow answer.
The only caveat is that css variables are not supported by IE nor Edge.
To change cursor to vertical bar you can use this css:
toggle highlight.cmd .cursor.blink {
color: #aaa;
border-left: 1px solid #aaa;
background-color: black;
margin-left: -1px;
}
.terminal .inverted, .cmd .inverted, .cmd .cursor.blink {
border-left-color: #000;
}
@-webkit-keyframes terminal-blink {
0%, 100% {
border-left-color: #aaa;
}
50% {
border-left-color: #000;
}
}
@-ms-keyframes terminal-blink {
0%, 100% {
border-left-color: #aaa;
}
50% {
border-left-color: #000;
}
}
@-moz-keyframes terminal-blink {
0%, 100% {
border-left-color: #aaa;
}
50% {
border-left-color: #000;
}
}
@keyframes terminal-blink {
0%, 100% {
border-left-color: #aaa;
}
50% {
border-left-color: #000;
}
}
- .cmd .cursor.blink {
- color: #aaa;
- border-left: 1px solid #aaa;
- background-color: black;
- margin-left: -1px;
- }
- .terminal .inverted, .cmd .inverted, .cmd .cursor.blink {
- border-left-color: #000;
- }
- @-webkit-keyframes terminal-blink {
- 0%, 100% {
- border-left-color: #aaa;
- }
- 50% {
- border-left-color: #000;
- }
- }
-
- @-ms-keyframes terminal-blink {
- 0%, 100% {
- border-left-color: #aaa;
- }
- 50% {
- border-left-color: #000;
- }
- }
-
- @-moz-keyframes terminal-blink {
- 0%, 100% {
- border-left-color: #aaa;
- }
- 50% {
- border-left-color: #000;
- }
- }
- @keyframes terminal-blink {
- 0%, 100% {
- border-left-color: #aaa;
- }
- 50% {
- border-left-color: #000;
- }
- }
From 1.0.0 version you can simplify this using this css:
toggle highlight.terminal {
--color: rgba(0, 128, 0, 0.99);
--background: white;
--animation: terminal-bar;
}
- .terminal {
- --color: rgba(0, 128, 0, 0.99);
- --background: white;
- --animation: terminal-bar;
- }
If you need to support IE or Edge you can set animation using:
toggle highlight.cmd .cursor.blink {
-webkit-animation-name: terminal-underline;
-moz-animation-name: terminal-underline;
-ms-animation-name: terminal-underline;
animation-name: terminal-underline;
}
.terminal .inverted, .cmd .inverted {
border-bottom-color: #aaa;
}
- .cmd .cursor.blink {
- -webkit-animation-name: terminal-underline;
- -moz-animation-name: terminal-underline;
- -ms-animation-name: terminal-underline;
- animation-name: terminal-underline;
- }
- .terminal .inverted, .cmd .inverted {
- border-bottom-color: #aaa;
- }
Or this css for bar cursor:
toggle highlight.cmd .cursor.blink {
-webkit-animation-name: terminal-bar;
-moz-animation-name: terminal-bar;
-ms-animation-name: terminal-bar;
animation-name: terminal-bar;
}
.terminal .inverted, .cmd .inverted {
border-left-color: #aaa;
}
- .cmd .cursor.blink {
- -webkit-animation-name: terminal-bar;
- -moz-animation-name: terminal-bar;
- -ms-animation-name: terminal-bar;
- animation-name: terminal-bar;
- }
- .terminal .inverted, .cmd .inverted {
- border-left-color: #aaa;
- }
From version 1.11.0 there are handy css classes (underline-animation and bar-animation) that need to be added to terminal element, so you don't overwrite your css variables.
To change the color of the cursor with differerent animation that will work in IE or Edge you will need to create new @keyframes
with different colors, like in previous examples.
To change font size of the terminal you can use this code:
toggle highlight.terminal, .cmd, .terminal .terminal-output div div, .cmd .prompt {
font-size: 20px;
line-height: 24px;
}
- .terminal, .cmd, .terminal .terminal-output div div, .cmd .prompt {
- font-size: 20px;
- line-height: 24px;
- }
Or from version 1.0.0 (and if you don't care about IE or Edge) you can simplify the code using --size css variables like this:
The size is relative to original size so 1 is normal size, 1.5 is 150% and 2 is double size.
You can take a look at the demo.
From version 1.10.0 you can use --link-color
to change color of the links. From this version links now change background to color and color to background on hover.
From version 1.7.0 you can use new :focus-within
pseudo selector to change style when terminal or cmd is in focus:
toggle highlight.cmd:focus-within .prompt * {
color: red;
}
- .cmd:focus-within .prompt * {
- color: red;
- }
From version 1.15.0 (thanks for PR from David Refoua) you can use --error-color
to change color of errors
You can check it out in this codepen
If you want terminal to look like from OSX, Ubuntu or Winows 10 you can take a look at shell.js library, I've used its css with some tweaks to work with jQuery Terminal. See codepen demo
How to add glow to the terminal
Here is proper code that add glow:
toggle highlight#term {
--color: rgba(0, 200, 0, 0.99);
--animation: terminal-glow;
text-shadow: 0 0 3px rgba(0, 200, 0, 0.6);
}
.terminal .terminal-output > :not(.raw) .error,
.terminal .terminal-output > :not(.raw) .error * {
text-shadow: 0 0 3px rgba(200, 0, 0, 0.6);
}
.terminal .terminal-output > :not(.raw) a[href] {
text-shadow: 0 0 3px rgba(15, 96, 255, 0.6);
}
- #term {
- --color: rgba(0, 200, 0, 0.99);
- --animation: terminal-glow;
- text-shadow: 0 0 3px rgba(0, 200, 0, 0.6);
- }
- .terminal .terminal-output > :not(.raw) .error,
- .terminal .terminal-output > :not(.raw) .error * {
- text-shadow: 0 0 3px rgba(200, 0, 0, 0.6);
- }
- .terminal .terminal-output > :not(.raw) a[href] {
- text-shadow: 0 0 3px rgba(15, 96, 255, 0.6);
- }
terminal-glow animation will be new animation in version 2.1.0, you can test this in devel branch.
This will make sure that links have blue and errors red glow.
$.terminal.formatter
is object that use new features of ECMAScript that allow to use normal object in place of regular expression.
It work in any major browser except IE.
You can use this object like Regex in search/match/replace/split string methods, and it use internal regexes (it would be hard to name all different regular expressions used for different tasks) to do all those actions.
toggle highlightvar re = $.terminal.formatter;
var str = 'aa[[;blue;]bb] cc [[;red;]] dd';
// split is handled by $.terminal.split_formatting that split formatting
// and text but it remove empty strings.
console.log(str.split(re));
// in replace each part of the formatting is in its own capturing
// group (except brackets and semicolons)
// both of those remove formatting from string, same as $.terminal.strip
console.log(str.replace(re, function(_, style, color, background) {
return arguments[6];
}));
console.log(str.replace(re, '$6'));
// this will return array of all instances of formatting from string
console.log(str.match(re));
// this will return index of first formatting
console.log(str.search(re));
- var re = $.terminal.formatter;
-
- var str = 'aa[[;blue;]bb] cc [[;red;]] dd';
- console.log(str.split(re));
-
-
- console.log(str.replace(re, function(_, style, color, background) {
- return arguments[6];
- }));
- console.log(str.replace(re, '$6'));
-
- console.log(str.match(re));
-
- console.log(str.search(re));
-
formatter don't work with extended commands, so the brackets need to have at least 2 semicolons.
Formatters are a way to format strings in different way. You can create syntax highligher with it. Formatter is a function that get string as input and return terminal formatting see echo method (it can also be array with regex and replacement where replacement can be string or function like in normal string::replace). To add new formatter you simply push (or unshift if you want the benefits of nested formatting) new function to $.terminal.defaults.formatters, by default there is one formatter for nested formatting so you can echo [[;red;]red[[;blue;]blue] also red]
and there are 2 files (xml_formatting.js and unix_formatting.js) with formatters in js directory on github, there is also SQL syntax example and Syntax hightlighter using PrismJS in prism.js file.
From version 1.10.0 formatter can be an array with regex and replacement string or function, the second option is requried if you want your formatter that change the length of the text like with emoji demo. Regex formatter have also 3rd argument which can be object with options (right now only one option is avaible which is loop nad keep replacing until it don't find match).
From same version formatter function can have special property __meta__
set to true (used by nested formatter) that allow to process whole text including formatting, instead of just text between formatting. It was created for internal use, but you can use it in your own code.
From version 1.19.0 formatter can return array [string, position] and it pass cursor position as option, if you're using replacement that change length of the string (like in emoji demo) you can using utility tracking_replace that return array with string and position like is recomended by new formatters.
Cursor Position
If you have formatter that change length of the string you will have strange cursor position when you move using arrow keys. There are two different cursor positions you move in original cursor position on input command and you get display of virtual cursor on output string so it sometimes stay in the same position like with emoji demo (you will be after emoji while original cursor is inside word that is used to created emoji so you can delete any key inside the word). There are also two functions to move the cursor (on original text display and display_position to move virtual one).
There are 3 keyboard events (all of them you can add in terminal, cmd and push command):
- keymap — simpler events you can add uppercase shortcut like CTRL+V, the callback function is
function(e, original) {
, the original is original function callback that can be called, because your function overwrite original behvaior.
- keydown — this event is fired before keymap so you can return false to prevent default keymap
- keypress — is used to handle inserting of characters if you want to prevent certain characters to be inserted you can return false for those characters.
Caveats: the shortcut CTRL+D is handled by both keydown and keymap. If terminal is paused is handled by keydown and if not in keymap. If you want to overwrite CTRL+D when terminal is paused you need to pass false to pauseEvents option and use keydown otherwise you need to add function to keymap.
You can provide your authentication function which will be called when user enter login and password. Function must have 3 arguments first is user name, second his password and third is callback function which must be called with token or falsy value if user enter wrong user and password. (You should call server via AJAX to authenticate the user).
You can retrieve token from terminal using token method on terminal instance. You can pass this token to functions on the server as first parameter and check if it's valid token.
If you set interpreter to string (it will use this string as URI for JSON-RPC service) you can set login function to string (to call custom method on service passed as interpreter) or true (it will call login method).
If you set URI of JSON-RPC service and login to true or string, it will always pass token as first argument to every JSON-RPC method.
From version 1.16.0 you can return promise of a token from login function.
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. 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.
One more thing to mention that if you're using raw option to
echo back stuff from users (and show it other users), you're also vulnerable to XSS like in
any application. So if you wan to do that you need to sanitize user input.
You can
find ways to bypass
XSS filtering on OWASP. The best is always a whitelist of things that is possible to
enter by the users.
NOTE: XSS is possible only when you have application that echo back
stuff from your users, like with chat application, guest book or when you save state in url hash and allow to execute it together with echo stuff from
users. If you don't do that and you control what is echo on terminal you're fine with any
options terminal provide.
NOTE 2: To disable exec if you have `execHash` (or echo stuff from users
with `invokeMethods: true`), you can also set option `{exec: false}` to your `echo` call and
use it only when you get values from server (not from DB indireclty from users). If you do
this you will be able to echo stuff from users and execute terminal methods from server
(this feature is mostly done just for that).
Third party code and additional plugins
Terminal include this 3rd party libraries:
- Storage plugin by Dave Schindler.
- jQuery Timers.
- Cross-Browser Split 1.1.1 by Steven Levithan.
- jQuery Caret by Gideon Sireling.
- sprintf.js by Alexandru Mărășteanu.
- unix_formatting use node-ansiparser by Joerg Breitbart
terminal also define this helper functions:
Additional files:
From version 1.20.0 every file is UMD module.
-
unix_formatting.js — The file is defining two formatters $.terminal.overtyping
(that handle output from man command, backspaces and ANSI code \x1b[K that clear line) and $.terminal.from_ansi
(that handle graphic ANSI escape codes) and adding them to the beginning of $.terminal.defaults.formatters, so if ANSI escape generate nested formatting it will be picked up by nesting formatter defined in jQuery Terminal source code.
-
prism.js — contain monkey patch for PrismJS library (for syntax highlighting) that output terminal formatting. To use it you need to include PrimsJS JavaScript and CSS files.
toggle highlight<link rel="stylesheet prefetch" href="https://cdn.jsdelivr.net/npm/prismjs@1.14.0/themes/prism.css"/>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.14.0/prism.min.js"></script>
- <link rel="stylesheet prefetch" href="https://cdn.jsdelivr.net/npm/prismjs@1.14.0/themes/prism.css"/>
- <script src="https://cdn.jsdelivr.net/npm/prismjs@1.14.0/prism.min.js"></script>
-
then after you include PrismJS you need to include terminal prism monkey patch and then you can use
$.terminal.prism(language, text)
. By default prism include only css,js and markup (html) grammars. To include more you need to load appropriate js files. If no language is found the function returns unmodifed text.
First argument is language so you can bind with fixed language and add that function to formatters array:
toggle highlight$.terminal.defaults.formatters.push(
$.terminal.prism.bind(null, 'javascript')
);
- $.terminal.defaults.formatters.push(
- $.terminal.prism.bind(null, 'javascript')
- );
-
From version 1.18.0 you can use helper $.terminal.sytnax.
This is preferable way to have syntax highlighting ('website' is special language addded in version 1.18.0 and renders html, css and javascript).
-
less.js — this file contain jQuery plugin that can be use with terminal (and since terminal instance if extension of jQuery object you can invoke it like terminal method).
toggle highlight$('body').terminal({
less: function(file) {
// this is terminal instance and arrow function allow to use
// this from outside
$.get(file, (text) => this.less(text));
}
});
- $('body').terminal({
- less: function(file) {
-
-
- $.get(file, (text) => this.less(text));
- }
- });
- dterm.js — contain jQuery plugin
dterm
that is combination of jQuery UI Dialog and jQuery Terminal.
-
xml_formatting.js — created as example of formatter. By including this file it allow to use xml syntax to color text (using echo).
toggle highlight<red>foo <green>bar</green> baz</red>
- <red>foo <green>bar</green> baz</red>
-
-
ascii_table.js — Define UMD module with ascii_table function that return simple ASCII table, like the one from mysql cli command. it have wcwidth as dependecy, in browser it's optional.
-
pipe.js — defines experimental pipe interpreter (it support | and custom redirects) see pipe example.