#shell

app nsh

A command-line shell written in Rust that focuses on performance and productivity

10 releases

✓ Uses Rust 2018 edition

new 0.2.1 Dec 2, 2019
0.2.0 Nov 2, 2019
0.1.5 Aug 31, 2019
0.1.3 Jun 4, 2019
0.0.3 Dec 19, 2018

#100 in Command line utilities

Download history 7/week @ 2019-08-19 26/week @ 2019-08-26 45/week @ 2019-09-02 14/week @ 2019-09-09 110/week @ 2019-09-16 28/week @ 2019-09-23 14/week @ 2019-09-30 1/week @ 2019-10-07 9/week @ 2019-10-14 20/week @ 2019-10-21 16/week @ 2019-10-28 29/week @ 2019-11-04 4/week @ 2019-11-11 30/week @ 2019-11-18 21/week @ 2019-11-25

109 downloads per month

CC0-1.0 OR MIT

350KB
9K SLoC

nsh

Build Status Latest version

Currently nsh is incomplete and not yet stable. Succeeded in crashing nsh? Let me know!

A command-line shell that focuses on performance and productivity featuing:

  • A not-yet-completed-but-aims-to-be Bash compatible interactive shell.
  • Tab completions and syntax highlighting like fish.
  • A builtin interactive fuzzy completion filter like fzf.
  • Builtin zero configration features and web-based config editor: nsh-config.
  • Written in Rust 🦀

screenshot

Installation

$ cargo install nsh

To enable completions, install (bash-completion). If you are using macOS, install newer Bash as well:

$ brew install bash bash-completion@2

Configuration

Set the following variables in ~/.nshrc:

  • $PATH
  • $PROMPT: The prompt format. See prompt.md for details.

Key Shortcuts

Key Action
Up Select the previous history.
Down Select the next history.
^C Clear the input.
^L Clear the screen.
^W Delete the previous word.
^K Delete from cursor to the end of input.
M-f (Alt+Right) Move the cursor to the next word.
M-b (Alt+Left) Move the cursor to the previous word.
^A Move the cursor to the beginning of input.
^E Move the cursor to the beginning of input.
TAB Enter the completion mode.
^R Enter the history search mode.

Why create a new shell?

Bash is the best for executing shell scripts but its interactive mode is not satisfactory. I am a zsh user for the last decade but I don't need customizability and got tired of making my zshrc faster. Fish is really neat but I prefer old-fashioned, traditional, and ergonomic shell syntax.

Comparisons

nsh bash zsh fish PowerShell
POSIX shell features Yes Yes Yes original syntax No
Bash compatibility partially supported 100% compatible provides emulate(1) requires Bass No
Prompt UX (aims to be) awesome minimum standard comfortable awesome comfortable
Configuration easiness web-based config insufficient oh-my-zsh or very long zshrc web-based config insufficient
Name not bad noble cool cute super cool

Building

Prerequisites

  • macOS or Linux
  • Rust 1.31.0 or higher
$ cargo build --release
$ ./target/release/nsh

Testing

$ cargo test
$ ./run-tests.py

Debugging

The debug log file is located at ~/.nsh.log. To enable debug log, run nsh with RUST_LOG evironment variable (i.e., $ RUST_LOG=nsh=trace nsh).

Contributing

nsh is in alpha stage: there are many missing features which Bash provides, there are kludges in source code, and there must be bugs. To make nsh practical for daily use, I need your help!

How can I contribute?

  • Report bugs in GitHub issues. Please attach a minimal reproducible example (e.g. shell script) if possible. It helps me to fix the bug easier.
  • Suggest enhancements in GitHub issues.
  • Submit a Pull Request which implements a new feature, fixes a bug, refactors code, rephrases sentences in documentation, etc.

License

CC0 or MIT. Choose whichever you prefer.

Dependencies

~5.5MB
~95K SLoC