Skip to content

A shell made in NodeJS, customizable and scriptable with Javascript, and compatible with traditional UNIX shells

License

Notifications You must be signed in to change notification settings

bteixeira/nodeshell

Repository files navigation

nodeshell

What do you do when you get tired of your shell?
That's right, you make your own.

Current Status: Almost stable. Some features missing or poorly implemented.

This project was born out of some disappointment with the customization possibilities of nowadays shells.
Shells like Bash and Zshell work quite well and are armed with a bunch of features, but they are really hard to customize if you're not up for reading epic size documentation and learn all the quirks and corner cases of weird mini-languages created haphazardly for a single purpose.

How to get it and run it

git clone https://github.com/bteixeira/nodeshell.git
cd nodeshell
npm install
npx tsc
npm start

That should take you to a command line.
Here you can do the following:

  1. Type valid Javascript expressions to be evaluated; or
  2. Type commands as you would in any other shell
    1. You can pass the result of Javascript expressions as command arguments by wrapping them in parentheses

Try it out!

$ var getDir = function () {return 'nodeshell';}
undefined

$ cd ..
undefined

$ cd (getDir())
undefined

$ ls
LICENSE  node_modules  package.json  proto  README.md  shell.js  src  test  TODO.txt
0

What else does it do?

If a file named .nsh.js exists in your home directory, it will be executed on startup.
If a file with the same name exists in the local directory, it will be executed after that.

To change the text used as prompt, call NSH.lineReader.setPrompt(). If the argument you pass is a function, it will be executed (synchronously -- be careful with loops!) every time the prompt has to be shown, and its return value used for the prompt. If you assign any other value, that value will be converted to a string and used as the prompt.

A sample .nsh.js file is included which sets up a prompt with a little more information than the default.

Other features common in shells are also already implemented, like expanding ~ to your home directory and command history (with up and down keys).

Current Issues

Need to define:

  • Global API (objects and methods available)
  • Built-ins

Rewrite:

A couple of pieces are still remnants of the first prototype I made and have to be rewritten (not even refactored):

  • CommandSet (commands.js)
  • KeyHandler
  • Line lalala

About

A shell made in NodeJS, customizable and scriptable with Javascript, and compatible with traditional UNIX shells

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published