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.
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:
- Type valid Javascript expressions to be evaluated; or
- Type commands as you would in any other shell
- 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
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).
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