{"id":22473142,"url":"https://github.com/bas080/termjs","last_synced_at":"2025-10-12T03:32:12.741Z","repository":{"id":27544132,"uuid":"31025655","full_name":"bas080/termjs","owner":"bas080","description":"Command Line Interface in browser","archived":false,"fork":false,"pushed_at":"2016-01-14T13:05:09.000Z","size":11503,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T16:30:56.211Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bas080.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-19T16:52:51.000Z","updated_at":"2015-02-19T16:58:15.000Z","dependencies_parsed_at":"2022-07-24T22:16:26.422Z","dependency_job_id":null,"html_url":"https://github.com/bas080/termjs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bas080/termjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Ftermjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Ftermjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Ftermjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Ftermjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bas080","download_url":"https://codeload.github.com/bas080/termjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Ftermjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279010148,"owners_count":26084692,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-06T12:19:36.257Z","updated_at":"2025-10-12T03:32:12.706Z","avatar_url":"https://github.com/bas080.png","language":"JavaScript","readme":"jUnix\n=====\njUnix is a javascript library which enables developers to add a command line\ninterface like interaction to their browser projects. See this \u003ca\nhref='demo.html'\u003eDEMO\u003c/a\u003e to see what I mean. \n\nThe plan is to make a command line interface style console in a browser. The\ngoal is to make something fun and usefull. However I will try to leverage \nthe power of javascript and not just copy unix console features blindly. A vim\nlike editor would be awesome though!\n\nModularity is important. It should be relatively easy to change and extend\nfeatures, while keeping the core small.\n\nLet's go over the features.\n\nFeatures\n--------\n###Command line interface (CLI)\n**Command line interface-ish interaction.** It basicly simulates a terminal's\ninteraction. Including things like pipes *|*, paralell *\u0026* and sequential *\u0026\u0026*\ncommands.\n\n###Commands\nExcept for being able to run builtin \"pure\" javascript functions, it is also possible to\nregister commands and use them in a similar way to a unix system. You can also\ncombine these two. The registered packages and commands can be seen with the\nfollowing commands.\n\n```bash\n\u003e commands #shows all commands available\n\n\u003e packages #shows all packages registered\n\n\u003e manual commands #shows the manual page of the \"commands\" command\n```\n\nUse **manual** *command_name* to read more about that command. This wil only work\nif manual variable is defined in the command its definition.\n\nThese commands should help you get on you way. It should feel natural if you are\na unix user.\n\n###API\n**A simple API.** \nIt allows the registering of commands and shortcuts. Furthermore it has\nfunctions to interact with other elements of the jUnix terminal.\n\n**register command**\n```javascript\n//simple example of the echo command\nterm.command.register( 'echo', function(){ //is a constructor\n  this.on_command = function(p, i){ //p are the parameters in an array and i is the pipe input. Will be undefined if none is given\n    return p.slice( 1 ).join(' ');\n  };\n});\n```\n\n**register shortcut**\n```javascript\nterm.keyboard.register( 'Ctrl c', function( ){\n  term.input.value(''); //set the input line to nothing\n});\n```\n\n**register alias**\n```javascript\nTODO\n```\n\n**Getting and setting input line values**\n```javascript\n//Get or set the string after the cursor.\nterm.input.post();\n  //or\nterm.input.post( string );\n\n//Get or set the cursor string value\nterm.input.cursor();\n  //or\nterm.input.cursor( string );\n\n//Get ir set the text before the cursor\nterm.input.pre();\n  //or\nterm.input.pre( string );\n```\n\n###packages\nA package is a bundle of commands, shortcuts functions and/or data. \n\nUsing packages makes it easier for users to load and unload the packages they\nwant. It also enables developers to easily version and bundle their commands.\n\nIt is easy to make a package. Packages can be loaded with the \"load\" command.\nThis command is defined in the \"term/packages/default.js\". The load command is\nfurther explained in the **commands** section.  \nWhat makes a package different compared to a normal javascript file is the\nfollowing.\n\nPackage files have the \"term.package.register\" function. They should always be\ndefined at the top of the file. If not it will not register what commands and\nshortcuts belong to it. Let's look at an example of a package register function.\n\n```javascript\nterm.package.register({\n  name:         'regex',        //name of the package. Consider this the identifier\n  version:      0.4,            //important for checking if user hase latest version.\n  version_name: 'regelisious'   //cause I can\n});\n\n//example of the registering of a command\nterm.command.register( 'random', function(){\n  this.on_command = function(){\n    return Math.random();\n  };\n});\n```\n\nTechnically it is possible to register multiple packages in the same file. For\nmodularity sake I do not advice it.  \nThe load command will remember what file\nbelongs to what package. This makes it easy to find out what package belongs to\nwhat javascript file. Use the **packages** command to see all packages and their\nfilename. It is adviced to keep the package name and the javascript file name\nthe same for ease of use.\n\n```javascript\n//example of packages command output TODO\n```\n\nCommands and shortcuts that are registered beneath the package function will be\nconsidered part of that package. You can see what package a command belongs to\nby using the command **package** *command_name*. When removing a package with\n**unload**, it removes the shortcuts and commands registered to it.\n\nSetup\n-----\n**Initiating a \"terminal\" requires the following.**\n\n*Add to \u003chead\u003e ... \u003c/head\u003e*\n```html\n  \u003cscript src=\"scripts/libs/term.js\"    type=\"text/javascript\" charset=\"utf-8\"\u003e\u003c/script\u003e\n  \u003cscript src=\"scripts/cmds/install.js\" type=\"text/javascript\" charset=\"utf-8\"\u003e\u003c/script\u003e\n  \u003cscript src=\"scripts/cmds/default.js\" type=\"text/javascript\" charset=\"utf-8\"\u003e\u003c/script\u003e\n```\n\nBy default it wil render the terminal in the element with id='terminal'. This\ncan be changed in the *term.js* on the last line of the file.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbas080%2Ftermjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbas080%2Ftermjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbas080%2Ftermjs/lists"}