A custom C# interactive shell, customizable.
NShell is a lightweight, extensible shell written in C# using [.NET 8.0+].
It's designed for hackers, shell lovers, and those who enjoy boot sequences.
- β Custom interactive shell interface
- β Built-in command loader with registration system
- β
Command metadata (
Description,IsInteractive,RequiresRoot, etc.) - β
Handle customs commands, but load also
/usr/bin,/usr/sbin..ect commands. - β Spectre.Console markup support for colors, glitches, animations
- β Full AOT support (with manual command registration)
- β Future-proof extensibility (plugin-style architecture)
- β Tab completion for commands and file paths
- β Command history with Ctrl+R reverse search
- β Command aliases (alias/unalias)
- β Environment variable management (export/unset/printenv)
- β Word-based cursor navigation (Ctrl+Left/Right)
- β Rich built-in commands (help, history, which, pwd, echo, clear, exit)
- β Output redirection (>, >>)
- β Command chaining (&&, ||, ;)
- β Basic piping support (|)
Clone the repo and install:
git clone https://github.com/onihilist/NShell.git
cd NShell
chmod +x install.sh
./install.shThis is a little exemple of an custom theme.
If you are using format_top/bottom & corner_top/bottom, format will be ignored.
For making a single line prompt use format, and double line format_top/bottom.
N.B : path_slash_color & path_words_color works with single and double line shell prompt.
Exemple :
{
"name": "test",
"format": "[bold green][[{user}@{host}]][/][white][[{cwd}]] >>[/]",
"format_top": "[[[bold cyan]{user}[/]@[bold cyan]{host}[/]]]",
"format_bottom": "[[{cwd}]]",
"corner_top": "[bold magenta]\u250c[/]",
"corner_bottom": "[bold magenta]\u2514[/]",
"ls_colors": "di=34:fi=37:ln=36:pi=33:so=35:ex=32",
"path_slash_color": "cyan",
"path_words_color": "yellow"
}The name of the theme is test, no matter what the file is named.
So enter the command : settheme test.
This is the result :
Since version 0.5.0, you can build your own plugin (DLL) and add this to NShell. This is a simple exemple :
using NShell.Shell.Commands;
using NShell.Shell;
using Spectre.Console;
namespace HelloPlugin
{
public class HelloPlugin : ICustomCommand
{
public string Name => "hello";
public HelloPlugin()
{
CommandRegistry.Register(this);
}
public void Execute(ShellContext context, string[] args)
{
AnsiConsole.MarkupLine("[green]Hello from HelloPlugin![/]");
}
}
}And DON'T FORGET TO USE THE SAME IMPORTS AS NSHELL !
With the same version of Spectre.Console (0.50.0)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../NShell/NShell.csproj"/>
<PackageReference Include="Spectre.Console" Version="0.50.0" />
</ItemGroup>
</Project>
- [PROGRESS] Plugin support (dynamic loading)
- [OK] Fix neofetch shell version
- [OK] Fix interactive commands/scripts running configuration
- [OK] Autocomplete
- [OK] Command history
- [OK] Profiles and theme switching
- [OK] Remove Bash FallBack
- [OK] Themes & ThemeLoader
NShell comes with a rich set of built-in commands:
| Command | Description |
|---|---|
help |
Display all available commands with descriptions |
about |
Display information about NShell |
exit |
Exit the shell gracefully |
clear |
Clear the terminal screen |
cd <dir> |
Change directory |
pwd |
Print current working directory |
echo <text> |
Display text (supports variable expansion) |
history [n] |
Show command history (optionally last n commands) |
alias name='cmd' |
Create command alias (persisted across sessions) |
unalias name |
Remove command alias |
export VAR=value |
Set environment variable |
unset VAR |
Remove environment variable |
printenv [VAR] |
Print environment variables |
which <cmd> |
Show path to command |
settheme <name> |
Change shell theme |
Keyboard Shortcuts:
Tab- Auto-complete commands and pathsCtrl+R- Reverse history searchCtrl+A/Home- Move cursor to start of lineCtrl+E/End- Move cursor to end of lineCtrl+Left/Right- Move cursor by wordUp/Down- Navigate command history
Advanced Shell Features:
- Command chaining with
&&(run if previous succeeded),||(run if previous failed), and;(always run) - Output redirection with
>(overwrite) and>>(append) - Basic piping with
|(pipe output between commands) - Smart command suggestions with "Did you mean...?" for typos
- Persistent aliases (saved in
~/.nshell/nshellrc.json)
Examples:
# Chain commands
echo "Building..." && dotnet build && echo "Success!" || echo "Failed!"
# Redirect output
echo "Hello World" > output.txt
history 50 >> history.log
# Use aliases (persisted across sessions)
alias ll='ls -la'
ll
# Environment variables
export MY_VAR="Hello"
echo {MY_VAR}
# Fast startup
nshell --no-bannerIf you have any problem with NShell, or it locks you out of a proper shell,
you can forcefully switch back to bash like this:
sudo sed -i "s|/usr/local/bin/nshell|/bin/bash|" /etc/passwdIf you got the error "bad interpreter" when running install.sh try to run this :
sudo apt update
sudo apt install dos2unix
dos2unix install.sh

