Recently I've been working with JS and I'm very enthusiastic about this language. I know that there is node.js for running JS at server side, but is there a shell that uses JS as a scripting language? If such thing exists, how usable & stable is it?

4 Answers 4


Does this look desirable to you?

// Replace macros in each .js file
ls('*.js').forEach(function(file) {
  sed('-i', 'BUILD_VERSION', 'v0.1.2', file);
  sed('-i', /.*REMOVE_THIS_LINE.*\n/, '', file);
  sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, cat('macro.js'), file);

If so, ShellJS could be interesting, it's

a portable (Windows included) implementation of Unix shell commands on top of the Node.js API.

I'm unsure if this could be used as a full-featured login shell, though. (Maybe with some wrapping?)

You could argue that it's not really a shell, but do you know TermKit? It's made of Node.js + Webkit, you could use JS to extend it (I guess); the shell language is still Bash(-ish).

  • Well, that looks cool! I'll give it a try.
    – J-unior
    Commented Dec 9, 2012 at 16:32
  • I technically don't really consider this a shell because it doesn't follow the cmd arguments syntax. For example psh adds such syntax to the perl language from my understanding so it appears more like a typical shell gnp.github.io/psh There might be a counter example but I haven't find it yet.
    – William
    Commented Oct 20, 2015 at 4:21
  • How would I set this as my login shell? Again I want something like this but I'm just not convinced this is it.
    – William
    Commented Nov 22, 2015 at 3:12
  • Still bash-ish, we could use sed({i:1}, 'BUILD_VERSION', 'v0.1.2', file) instead. Would be better to use async functions with await, so parallel would be faster.
    – inf3rno
    Commented Sep 13, 2017 at 11:40
  • ShellJS link is broken.
    – yO_
    Commented Oct 30, 2018 at 14:26

If you're on Ubuntu or any other debian based system, you may install rhino (from Mozilla.org).

sudo apt-get install rhino

It supplies js via alternatives:

=== /usr/bin/js is a symlink... following it
lrwxrwxrwx 1 root root 20 Nov 21 08:54 /usr/bin/js -> /etc/alternatives/js
=== /etc/alternatives/js is a symlink... following it
lrwxrwxrwx 1 root root 14 Nov 21 08:54 /etc/alternatives/js -> /usr/bin/rhino
=== /usr/bin/rhino is owned by package: rhino ===

So calling either rhino or js will give you a JavaScript shell.

Edit (2014-06-30):

rhino is good to quickly test some javascript code in a file, but it is not an interactive shell, so it doesn't support GNU readline style of editing. For interactive work, you may prefer nodejs: on Ubuntu/debian sudo apt-get install nodejs. This should provide a more interactive js shell (invoke using the command js) where you can edit lines and recall history with the up/down arrow-keys. For a longer list of options, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Shells


Mozilla INC offers a javascript shell : see Introduction_to_the_JavaScript_shell

Example of a shell in a system :

$ js
js> str = "welcome on *nix side" 
"welcome on *nix side"
js> str.indexOf("nix");          

No problems detected since I use it for testing purpose.

  • This is available on some/many linux distros now as a js package.
    – goldilocks
    Commented Dec 22, 2016 at 17:28

In Chrome and Firefox, if you press F12 it brings up developer tools. Over there you could find a tab called console, where you could type and test JavaScript scripts. It has code completion and other features too.

  • 7
    I think you didn't understand the question. I've asked about UNIX shell. But thanks for the willing to help anyway.
    – J-unior
    Commented Dec 9, 2012 at 14:54
  • 1
    This answers the question, "is there a shell that uses JS as a scripting language?". Nothing in the question talks about an alternative to bash or zsh (etc.) Commented Feb 5, 2018 at 21:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .