A node REPL with ShellJS loaded by default
npm install n_shell

A node REPL with ShellJS loaded by default.
This was inspired by (and forked from) n\_.
Give it a star on Github
``Bash`
$ npm install -g n_shell
Invoking n_shell starts a node REPL with ShellJS required globally, with
shell-like output:
`Bash`
bash $ n_shell
shelljs $ ls()
LICENSE
README.md
bin
node_modules
package.json
src
tmp
shelljs $ pwd()
/path/to/dir
No problem:
``
bash $ n_shell --no_global
shelljs $ typeof ls // not in the global namespace
'undefined'
shelljs $ shell.ls() // uses 'shell' prefix
LICENSE
README.md
bin
node_modules
package.json
src
tmp
shelljs $ shell.pwd()
/path/to/dir
You're covered:
``
bash $ n_shell --no_global=$
shelljs $ $.ls() // now uses '$' as the prefix
LICENSE
README.md
bin
node_modules
package.json
src
tmp
shelljs $ $.pwd()
/path/to/dir
Just install that version locally (npm install shelljs) and start upn_shell with the --path option:
``
bash $ n_shell --path=node_modules/shelljs
shelljs $
`javascript`
bash $ n_shell --noinspect
shelljs $ ls()
[ 'LICENSE',
'README.md',
'index.js',
'node_modules',
'package.json',
stdout: 'LICENSE\nREADME.md\nindex.js\nnode_modules\npackage.json\n',
stderr: null,
code: 0,
to: [Function],
toEnd: [Function],
cat: [Function],
head: [Function],
sed: [Function],
sort: [Function],
tail: [Function],
grep: [Function],
exec: [Function] ]
This supports any command that ShellJS supports. It also adds some extra
commands, for convenience. So far, this adds:
- shell.clear() (fromshell.open()
shelljs-plugin-clear)
- (fromshell.sleep()
shelljs-plugin-open)
- (from
shelljs-plugin-sleep)
- --global: Start a node REPL with the equivalent ofrequire('shelljs/global')
. This is the default behavior.--no_global [PREFIX]
- , --local [PREFIX], -n [PREFIX]: Start a node REPLvar PREFIX = require('shelljs')
with the equivalent of . PREFIX defaultsshell
to , if not specified.--use_strict
- : enforce strict mode (default is false)--prompt
- : use this format to generate the REPL prompt. Default isshelljs %v%l $
""%%
- : a literal % sign%v
- : show the current version (from package.json)%l
- : show [local] if this is using a local version of ShellJS--noinspect
- Want more format options? Let me
know or send me a
PR
- : disable the default --inspect behavior. This provides--path=path/to/shelljs/
less-readable REPL output, but behaves just as a standard Node REPL would.
- : the argument should be a path to a folder--inspect
containing a ShellJS package.
- (default): an experimental switch to add a .inspect() method toshell.pwd
the output of each command. The return values are still ShellStrings, but
appear more readable and shell-like. Also, commands with no arguments can be
invoked without parentheses, such as and shell.ls. Recommended
for ShellJS v0.7+. Credit for the idea goes to
piranna.
Similarly to n_, n_shell stores REPL history under ~/.n_shell_history`.