{"id":19836285,"url":"https://github.com/fooeybar/fshell","last_synced_at":"2025-10-23T20:32:37.478Z","repository":{"id":57242432,"uuid":"436366676","full_name":"Fooeybar/fshell","owner":"Fooeybar","description":"Simple mini shell","archived":false,"fork":false,"pushed_at":"2021-12-14T02:10:27.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T02:48:06.187Z","etag":null,"topics":["cli","commands","shell","stdin","stdout","terminal"],"latest_commit_sha":null,"homepage":"","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/Fooeybar.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":"2021-12-08T19:23:31.000Z","updated_at":"2024-02-05T03:35:15.000Z","dependencies_parsed_at":"2022-09-08T10:50:25.648Z","dependency_job_id":null,"html_url":"https://github.com/Fooeybar/fshell","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fooeybar%2Ffshell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fooeybar%2Ffshell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fooeybar%2Ffshell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fooeybar%2Ffshell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fooeybar","download_url":"https://codeload.github.com/Fooeybar/fshell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241202159,"owners_count":19926564,"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","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":["cli","commands","shell","stdin","stdout","terminal"],"created_at":"2024-11-12T12:10:50.408Z","updated_at":"2025-10-23T20:32:37.426Z","avatar_url":"https://github.com/Fooeybar.png","language":"JavaScript","readme":"# **fshell**\n\n![npm](https://img.shields.io/npm/v/fshell?style=flat-square)\n![node](https://img.shields.io/node/v/cu?style=flat-square)\n![license](https://img.shields.io/badge/License-MIT-blue.svg)\nMade with ![linux](https://img.shields.io/badge/Linux-FCC624?logo=linux\u0026logoColor=black)\n\n\u003c/br\u003e\n\nSimple mini shell\n\n\u003c/br\u003e\n\n---\n\n- [Initialization](#initialization)\n- [Parsing](#parsing)\n- [Syntax](#syntax)\n    - [Echo](#echo)\n    - [Multiple Execution](#multiple-execution)\n    - [Multiple Independent Execution](#multiple-independent-execution)\n    - [Multiple Dependent Execution](#multiple-dependent-execution)\n    - [Pipe](#pipe)\n- [Functions](#functions)\n    - [.cmd](#cmd)\n    - [.addCmd](#addCmd)\n    - [.renameCmd](#renameCmd)\n    - [.delCmd](#delCmd)\n    - [.getCmds](#getCmds)\n    - [.addFlag](#addFlag)\n    - [.delFlag](#delFlag)\n    - [.getFlags](#getFlags)\n    - [.error](#error)\n- [Flags](#flags)\n- [Commands](#commands)\n    - [cmds](#cmds)\n    - [.cwdclr](#cwdclr)\n    - [.textclr](#textclr)\n    - [.cursorclr](#cursorclr)\n    - [.history](#history)\n    - [.fileclr](#fileclr)\n    - [.dirclr](#dirclr)\n    - [exit](#exit)\n    - [cwd](#cwd)\n    - [cd](#cd)\n    - [ls](#ls)\n    - [mk](#mk)\n    - [rm](#rm)\n    - [cp](#cp)\n    - [mv](#mv)\n    - [ex](#ex)\n\n\u003c/br\u003e\n\n---\n\n## Initialization\n\n\u003c/br\u003e\n\n`fshell=require('fshell')({config});`\n\n\u003c/br\u003e\n\nAny config properties `undefined` or `typeof()!==` will default to the values listed below:\u003c/br\u003e\n\n- `.process: process`\n- `.textClr: 15`\n- `.cursorClr: 8`\n- `.cwdClr: 2`\n- `.fileClr: 6`\n- `.dirClr: 5`\n- `.errClr: 1`\n- `.history: 100`\n- `.escape: '\\x1b'`\n- `.onExit: function(code=0)`\n- `.onKey: function(key={sequence:'',name:'',ctrl:false,meta:false,shift:false})`\n\n\u003c/br\u003e\n\nReturns the config object with the added properties:\u003c/br\u003e\n\n- `.cmd: function(str,...) //Call commands`\n- `.addCmd: function(obj,...) //Add commands`\n- `.renameCmd: function(str,str,...) //Rename commands`\n- `.delCmd: function(str,...) //Delete commands`\n- `.getCmds: function() //Get array of command names`\n- `.addFlag: function(str,...) //Add option`\n- `.delFlag: function(str,...) //Delete option`\n- `.getFlags: function() //Get array of option strings`\n- `.error: function({}||(str,str,str,str,str)) //Log pretty format errors`\n\n[fstdin](https://github.com/Fooeybar/fstdin#readme) properties:\n\n- `.line: '' //Read-only current stdin`\n- `.key: function(str||obj,...) //Trigger keys`\n- `.prompt: function(obj,...) //Prompt user`\n- `.font: function(int) //Returns color code string`\n- `.back: function(int) //Returns color code string`\n\n\u003c/br\u003e\n\n---\n\n## Parsing\n\n\u003c/br\u003e\n\nAn incoming string will be parsed first for the `echo echo-in echo-out` flags and the command, ex: `echo ls`\u003c/br\u003e\nThe remainder of the string is parsed as arguments for the command until encountering a space, `|` , `\u0026` , or end of line.\n\n\u003c/br\u003e\n\n---\n\n## Syntax\n\n\u003c/br\u003e\n\n### Echo\n\nTo echo the input, or successful output, or both of a command execution, begin the line with `echo-in`, `echo-out`, or `echo`:\u003c/br\u003e\n\n```\n'echo-in mk hi/hi.js'\n\nprints:\n\n    [mk-0](hi/hi.js)\n    \n-----------------------------------------------------------\n'echo-out mk hi.js, hello/'\n\nprints: (print order based on async completion)\n\n    [mk-1](hello/)\n    [mk-0](hi.js)\n\n-----------------------------------------------------------\n'echo ls'\n\nprints:\n\n    [ls-0]()\n    ...command output...\n    [ls-0](${current directory})\n\n```\n\n\u003c/br\u003e\n\n### Multiple Execution\n\nTo execute a command multiple times separate the argument sets with a comma `,`:\n- `mk hi.js, hello.js`\n- `rm hi.js, hello.js`\n\n\u003c/br\u003e\n\n### Multiple Independent Execution\n\nTo execute multiple independent commands in one line:\n- Use a single `\u0026`\n- The commands will be executed regardless of the `end()` call of the prior command\n- Since most commands are asynchronous, this can cause unexpected behaviour\n- `mk hi.js \u0026 rm hello.js //expected behaviour`\n- `mk hi.js \u0026 rm hi.js //unexpected behaviour`\n\n\u003c/br\u003e\n\n### Multiple Dependent Execution\n\nTo execute multiple dependent commands in one line:\n- Use a double `\u0026\u0026`\n- The following command will be executed only if the prior command calls the `end()` function\n- `mk hi.js \u0026\u0026 rm hi.js //expected behaviour`\n\n\u003c/br\u003e\n\n### Pipe\n\nTo pipe the `end()` value of one command into the next command:\n- Use a `|`\n- The value passed to `end()` from each execution will be spread to the next command in front of any existing arguments\u003c/br\u003e\n\n```\n'mk hi.js | rm'\n\nmake and remove hi.js\n\n-----------------------------------------------------------\n'mk hi/hi.js | mv greetings/'\n\nmake hi/hi.js recursively and move to greetings/\nif greetings/ does not exist it is created\n\n-----------------------------------------------------------\n'mk hi.js, greetings/ | mv'\n\nmake hi.js and greetings/ and move hi.js into greetings/\n\n```\n\n\u003c/br\u003e\n\n---\n\n## Functions\n\n\u003c/br\u003e\n\n### cmd\n\n- Execute commands\n- Include the command and arguments in one string the same as typing on the command line and pressing return\n- Example: `cmd('mk hi/hi.js \u0026\u0026 rm hi/ -r')`\n\n\u003c/br\u003e\n\n### addCmd\n\n- Add a command if not previously defined\n- Requires an object with the properties:\n    - `.name : ''`\n    - `.func : function(){}`\n- Functions will always be passed the first two parameters `( flags, end )`; the remaining arguments are spread in order `( flags, end, arg1, arg2, arg3, ...)`\n    - `flags` is an object containing the flags passed in the argument set for the command\n        ```\n        addCmd({\n            name:'hw'\n            ,func:(flags,end)=\u003e{\n                if(flags.about)console.log('I print \"Hello world!\"');\n                else console.log('Hello world!');\n            }\n        });\n        ```\n    - `end` is a function, called when the command is fully finished\n        - Accepts one argument to pass to a piped command\n        - Required for `\u0026`, `\u0026\u0026`, and `|` pipe functionality\n        ```\n        addCmd({\n            name:'hw'\n            ,func:(flags,end)=\u003e{\n                if(flags.about)console.log('I print \"Hello world!\"');\n                else console.log('Hello world!');\n                end('Hello world!');\n            }\n        });\n        ```\n\n\u003c/br\u003e\n\n### renameCmd\n\n- Rename a command\n- Example: `renameCmd('mv','move','cp','copy')`\n\n\u003c/br\u003e\n\n### delCmd\n\n- Delete a command by name\n- Example: `delCmd('mv','cp')`\n\n\u003c/br\u003e\n\n### getCmds\n\n- Get an array list of command name strings\n- Example: `getCmds()`\n\n\u003c/br\u003e\n\n### addFlag\n\n- Add a flag if not already defined\n- Do not include the `-`\n- Example: `addFlag('version')`\n\n\u003c/br\u003e\n\n### delFlag\n\n- Delete a flag if defined\n- Do not include the `-`\n- Example: `delFlag('version')`\n\n\u003c/br\u003e\n\n### getFlags\n\n- Get an array list of flag name strings\n- Example: `getFlags()`\n\n\u003c/br\u003e\n\n### error\n\n- Pretty print error messages\n- Pass 5 optional string parameters:\n    - `error(command name, errno, code, path, message)`\n- Or add the command name to the error object and pass the object as the first parameter\n    - `err.cmd = command name`\n    - `error(err)`\n\n\u003c/br\u003e\n\n---\n\n## Flags\n\n\u003c/br\u003e\n\nFlags are options and are parsed out of the argument string.\u003c/br\u003e\n\nA flag begins with a dash, ex: `-about -last -r -x`.\u003c/br\u003e\n\nUse the `addFlag()` and `delFlag()` functions to add and remove flags.\u003c/br\u003e\n\n\u003c/br\u003e\n\nThe current default flags are:\n- `-about`\n- Get description of the command. When using the about flag, the corresponding command will not be executed\n\n\u003c/br\u003e\n\n- `-last`\n- Used with the `cd` command to change directory to the last working directory\n\n\u003c/br\u003e\n\n- `-r`\n- Recursive flag used with the `rm` command to recursively empty directories\n\n\u003c/br\u003e\n\n- `-x`\n- Overwrite flag used with the `mk`, `cp`, and `mv` commands to overwrite files and directories when existing\n\nWhile default flags are removable, they are irreplacable in the default commands.\n\n\u003c/br\u003e\n\n---\n\n## Commands\n\nThe pre-existing commands may be renamed or deleted.\n\n\u003c/br\u003e\n\n### cmds\n\n- Print a list of available commands\n- `cmds`\n\n\u003c/br\u003e\n\n### cwdclr\n\n- Set the current working directory colour code integer\n- `.cwdclr [int]`\n\n\u003c/br\u003e\n\n### textclr\n\n- Set the stdin text colour code integer\n- `.textclr [int]`\n\n\u003c/br\u003e\n\n### cursorclr\n\n- Set the stdin cursor colour code integer\n- `.cursorclr [int]`\n\n\u003c/br\u003e\n\n### history\n\n- Set the stdin scroll maximum history integer\n- `.history [int]`\n\n\u003c/br\u003e\n\n### fileclr\n\n- Set the 'ls' command file colour code integer\n- `.fileclr [int]`\n\n\u003c/br\u003e\n\n### dirclr\n\n- Set the 'ls' command directory colour code integer\n- `.dirclr [int]`\n\n\u003c/br\u003e\n\n### exit\n\n- Exit the fshell process and call the `onExit()` function; by default `int = 0`\n- `exit [optional int]`\n\n\u003c/br\u003e\n\n### cwd\n\n- Print the current directory\n- `cwd`\n\n\u003c/br\u003e\n\n### cd\n\n- Change the current directory\n- `cd [directory]`\n\n\u003c/br\u003e\n\n### ls\n\n- List a directory or array; by default `directory = current`\n- `ls [optional directory]`\n\n\u003c/br\u003e\n\n### mk\n\n- Make a file or directory\n- Defaults to file, to create a directory add `/` to the name\n- Requires the `-x` flag to overwrite existing files\n- `mk [file || directory+/]`\n\n```\n'mk hi'\n\nmakes file named 'hi'\n\n-----------------------------------------------------------\n'mk hi/'\n\nmakes directory named 'hi'\n\n-----------------------------------------------------------\n'mk hi/hi'\n\nmakes directory (if non-existant) named 'hi' and makes file named 'hi' in the directory\n\n```\n\n\u003c/br\u003e\n\n### rm\n\n- Remove files and directories\n- Requires `-r` recursive flag to remove non-empty directory\n- `rm [file || directory]`\n\n\u003c/br\u003e\n\n### cp\n\n- Copy files and directories to another directory\n- Will accept `.` or `*` at the path end to select all inside that directory\n- `cp [source file(s) || directory] [target directory]`\n\n```\n'mk hi/hi.js,hi/hello.js,hi/yo.js'\n'cp hi/ greetings/'\n\ncopy the 'hi' directory into the 'greetings' directory (created if non-existant)\n\n-----------------------------------------------------------\n'mk hi/hi.js,hi/hello.js,hi/yo.js'\n'cp hi/* greetings/'\n\ncopy all inside the 'hi' directory into the 'greetings' directory (created if non-existant)\n\n```\n\n\u003c/br\u003e\n\n### mv\n\n- Move files and directories to another directory\n- Will accept `.` or `*` at the path end to select all inside that directory\n- `mv [source file(s) || directory] [target directory]`\n\n```\n'mk hi/hi.js,hi/hello.js,hi/yo.js'\n'mv hi/ greetings/'\n\nmove the 'hi' directory into the 'greetings' directory (created if non-existant)\n\n-----------------------------------------------------------\n'mk hi/hi.js,hi/hello.js,hi/yo.js'\n'mv hi/* greetings/'\n\nmove all inside the 'hi' directory into the 'greetings' directory (created if non-existant)\n```\n\n\u003c/br\u003e\n\n### ex\n\n- Pass arguments to a separate OS shell process\n- `ex [arguments...]`\n```\n'echo ex echo \"Hello world!\", \"echo Hello back!\"'\n\nprints:\n\n    [ex-0](echo, Hello world!)\n    [ex-1](echo Hello back!)\n    [ex-0](Hello world!)\n    [ex-1](Hello back!)\n\n-----------------------------------------------------------\n'ex touch hi.js hello.js'\n\nuse separate OS shell to create hi.js and hello.js\n\n```\n\n\u003c/br\u003e\n\n---","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffooeybar%2Ffshell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffooeybar%2Ffshell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffooeybar%2Ffshell/lists"}