A fully functional Unix-like shell written from scratch in Rust.
Built as part of my journey to learn Rust systems programming and understand how shells work internally — from parsing commands to handling pipelines and redirections.
- Interactive prompt (
$) with input history - Built-in commands:
cd— change directorypwd— print current directoryecho— print textexit [code]— exit the shelltype— identify if a command is a builtin or externalhistory— view, read, write, or append command history
- Pipelines:
Supports multi-stage command chaining likecat file.txt | head -n 5 | wc -l
I made this project to learn Rust Rebuilding something as fundamental as a shell from the ground up helped me understand both Rust’s safety guarantees and how real shells like bash/zsh work internally.
echo hello > file.txt
echo again >> file.txt
cat file.txt 2> errors.log- Command autocompletion for builtins and executables in $PATH
- Persistent history through the HISTFILE environment variable
- Error handling for invalid commands, missing files, and pipes
- Parsing: Tokenizes user input, handling quotes, pipes, and redirects.
- Execution: Forks processes for external commands, connects pipes using libc and nix.
- Builtins: Runs in-process without forking.
- History: Managed in-memory with optional persistent storage via HISTFILE.
git clone https://github.com/<your-username>/Shell-Rust-Project.git
cd rust-shell
cargo build --release./target/release/Shell-Rust-ProjectHISTFILE=~/.my_shell_history ./target/release/Shell-Rust-Project- Rust standard library (std::process, std::fs, std::io)
- UNIX syscalls (fork, exec, pipe, dup2) via nix
- Rustyline for interactive input and autocompletion
- Manual command parsing, quoting, and redirection logic