Bemly's Shell — a Unix shell written in Rust with libc.
Inspired by lsh.
- Interactive REPL with colored prompt
- Command pipelines (
cmd1 | cmd2 | cmd3) - I/O redirection (
>,>>,<,2>) - Background jobs (
cmd &,jobs) - Tab completion (commands + file paths)
- Arrow key history navigation
- Line editing (Ctrl+A/E/K/U)
- Environment variable management
- Script execution (
.beshfiles) - Signal handling (Ctrl+C, Ctrl+Z)
- Job control
git clone https://github.com/Bemly/Besh.git
cd Besh
cargo build --releaseThe binary is at target/release/besh.
Optionally install to ~/.cargo/bin:
cargo install --path ../target/release/beshuser@hostname ~> ls -la
user@hostname ~> echo hello world
user@hostname ~> exit
./target/release/besh echo"hello world"
./target/release/besh ls -la /tmpcat > test.besh << 'EOF'#!/usr/bin/env beshecho "Running script"export VAR=valueecho $VARls -la | head -3EOF
./target/release/besh test.besh| Command | Description |
|---|---|
cd [path] | Change directory (supports ~) |
pwd | Print working directory |
echo [args...] | Print to stdout |
export VAR=val | Set environment variable |
unset VAR | Unset variable |
env | Print all environment variables |
set | Print all shell variables |
history [n] | Show last n commands |
jobs | List background jobs |
exit / quit / q | Exit shell |
# Pipe
cat file.txt | grep "pattern"| wc -l
# Output redirect
ls -la > listing.txt
# Appendecho"line">> file.txt
# Input redirect
sort < unsorted.txt
# Stderr redirect
ls /notfound 2> errors.txtsleep 60 &jobs- Press
Tabto complete commands and file paths - First word: completes built-in commands and executables from
$PATH - Other words: completes file/directory paths
- Multiple matches are displayed, common prefix is auto-completed
| Key | Action |
|---|---|
← / → | Move cursor |
↑ / ↓ | Navigate history |
Tab | Complete |
Ctrl+A | Move to start |
Ctrl+E | Move to end |
Ctrl+K | Delete to end of line |
Ctrl+U | Delete to start of line |
Ctrl+C | Cancel input |
Ctrl+D | EOF / exit |
export PATH=/usr/local/bin:$PATHexport EDITOR=vim
echo$HOMEecho$USERNO_COLOR=1 ./target/release/beshbesh Enter interactive shell
besh <command [args]> Execute a single command
besh <script.besh> Execute a script file
besh -h, --help Show help
besh -v, --version Show version
src/
├── main.rs Entry point
├── shell.rs REPL loop and command execution
├── parser.rs Command line parsing (pipes, redirects, variables)
├── process.rs Fork/exec/wait via libc
├── terminal.rs Raw mode, line editing, tab completion, colors
├── builtin.rs Built-in command implementations
├── environment.rs Variable management and prompt formatting
├── history.rs Command history with file persistence
├── job_control.rs Background/foreground job management
├── signal.rs SIGINT, SIGTSTP, SIGCHLD handlers
├── error.rs Error types
├── common_shell.rs Legacy stdlib-based shell (fallback)
└── better_truth_tty.rs Placeholder for future libc shell
API documentation is generated in docs/ via cargo doc.
libc— POSIX system callsdirs— Home directory detection
See LICENSE.