Nash is a command-line editor for bash
and compatible shells. It handles user input to provide a better user experience, and when the user hits the Enter
key, it simply passes the command to bash
for processing.
Nash is implemented in JavaScript and focuses on:
- Providing great UX and productivity to the command-line.
- Being highly extensible and customizable.
- Bringing shell power to JavaScript developers. Shells such as
zsh
orfish
are greatly configurable, but customizing them requires writing shell script code, which (for JS developers) is not as user-friendly as JavaScript. Extensions are written much faster in JS, and are easier to understand by the common developer.
- If you want to see how
nash
looks like, check some screenshots. - Check the user manual for a detailed description of
nash
functions.
- Flexible prompt, configurable by settings and by JavaScript code.
- Powerful command history navigation:
- The
up
anddown
keys navigate the history, showing only the entries that start with the current line. - The
page up
key displays a menu with all history lines that start with the current line.
- The
- Directory history navigation: the
page down
key displays a menu with the most recently visited directories, showing only the entries that contain the text in the current line. - Interactive tab-completion: pressing tab completes a file name, but if multiple matching files are available, a menu is displayed, letting the user navigate and select the file name. Completion supports other elements such as directories, command options and environment variables, and displays file information or option documentation depending on the case.
- All menus (command history, directory history and tab-completion) allow typing more characters to narrow the search.
- Syntax highlight, clearly coloring the different parts of a command, and warning of potential errors.
- History suggestions: when typing a command, if the text matches a previous command, the remaining text is displayed in grey, letting the user immediately complete the command.
- All these features are also available when establishing a connection with a
remote system, even if
nash
is not installed in the remote system: onlybash
is required. This is especially useful when:- Accessing restricted systems where installing
nash
is not easy or even not possible. - Accessing small or short-lived environments, such as a docker container.
- Accessing restricted systems where installing
- Configurable color palette. Colors can be configured by name (e.g. "red", "gren", etc.) or by RGB hex as in CSS (e.g. #a6e22e).
- Configuration and extensions are implemented as plain JavaScript code,
centered around the
~/.nash/nashrc.js
file, which is loaded during startup. Example configuration and extensions are provided in the~/.nash
directory, which is populated whennash
is started for the first time. For instance:- Color settings are configured via JSON - you can make your terminal use the same color palette
as your code editor. Most terminals support 16 million colors, and although this feature is
initially disabled in
~/.nash/nashrc.js
to ensure compatibility, it is really worth trying enabling it by uncommenting the line containingtrueColor: true
near the end of the file. - Keyboard shortcuts are reassigned using the
bindKey
API - the example in~/.nash/custom-keys.js
illustrates how to do it. TheF1
key displays the list of keyboard shortcuts, andctrl-k
displays the name of any key combination. - Completion helpers for known commands (git, docker, npm, etc.) are configured via JSON settings.
- Color settings are configured via JSON - you can make your terminal use the same color palette
as your code editor. Most terminals support 16 million colors, and although this feature is
initially disabled in
- An extensible plugin system which facilitates the addition of features.
Check the ToDo for a list of features under development and planned for the future. Suggestions are welcome.
If after a successful installation you get strange behavior, see Starting nash for troubleshooting. Also, check the Recommended prerequisites section below.
As usual:
$ npm install -g bnash # the "nash" name was taken in npm ¯\_(ツ)_/¯
Then just type bnash
to launch it.
If you get installation errors containing
node-gyp
in the error messages, this is because you need to install the native build tools first. That installation depends on the OS - for example, for Ubuntu the following command installs those prerequisites:$ sudo apt-get install build-essentialYou can get more details in the node-gyp installation document.
...Or you can just download the binary installation: see the next section.
The releases page contains binary packages for Linux and MacOS.
You can download the appropriate nash-[version]-[platform].tar.gz
file, then unpack it into a directory of your
choice. For example:
$ mkdir ~/nash-inst
$ cd ~/nash-inst
$ # Use the appropirate link for nash-[version]-[platform].tar.gz
$ curl -OL https://github.com/lcrespom/nash/releases/download/1.10.1/nash-1.10.1-linux.tar.gz
$ tar -xzf nash-1.10.1-linux.tar.gz
Finally, to run nash:
$ ./nash
To easily launch nash
in the future, you can copy the extracted files somewhere in your $PATH
.
An appropriate place is /usr/local/bin
:
$ sudo cp nash pty.node /usr/local/bin
From then on, you can simply launch it by typing nash
.
The binary distribution packages nash code along with the node.js runtime in a single executable, except for the
pty.node
file, which must be placed alongside. The packaging is done using the great pkg tool.
If you want to run nash
from the source code (and maybe help with development), just clone the repo and type npm install
. Then, to open a shell, type node src/nash
.
$ git clone https://github.com/lcrespom/nash.git
$ npm install
$ node src/nash
There is no direct Windows support, but an Ubuntu terminal can be installed in windows very easily through the Microsoft Store. See instructions here.
In order to get the best experience from nash
, the following prerequisites are recommended:
A collection of fonts that are optimized for the terminal and contain useful symbol characters, e.g. for displaying a fancy prompt, git repository symbol, etc. They can be downloaded form here.
Once the terminal is configured to use a powerline font, add the following entry in the exported
options
of .nash/nashrc.js
:
prompt: { powerFont: true }
This will tell the prompt plugin that it can use fancy symbol characters, e.g. for the git status.
The default terminal application that comes preinstalled with the OS is usually quite limited, and may
even cause defective output or glitches when nash
tries to generate colorful output. The recommended
alternatives are the following:
- Mac: iTerm2. Although the default terminal is quite powerful, it does not support 16 million colorws (see below).
- Windows:
- Windows Terminal. The GitHub page contains
instructions for different installation methods, and at the very beginning of the
README.md
there is a link to the app in the Microsoft Store, which is the easiest installation method. - The terminal provided by the Ubuntu WSL app is also quite decent.
- Windows Terminal. The GitHub page contains
instructions for different installation methods, and at the very beginning of the
- Linux: most Linux distributions come with a powerful terminal by default.
Once you are using a good terminal app, make sure you enable 16 million color support by uncommenting the
line trueColor: true
in the options
of .nash/nashrc.js
. Some pugins make use of this feature, but it is
disabled by default because there is no safe way to detect 16 million color support, and attempting
to use this feature on a terminal that does not support it results in unreadable output.
If you are thinking about using JavaScript to implement your shell scripts, check out ShellJS.
If you are looking for a full shell interpreter with good UX, check out Oh My Zsh and Fish Shell.