A fully functional mini command-line shell written in Rust, featuring support for:
✅ Command execution
✅ Directory navigation (cd)
✅ Output redirection (>)
✅ Piping between commands (|)
✅ Built-in exit command to gracefully quit
This project showcases how Rust’s std::process, std::io, and system-level abstractions can be combined to create a minimal yet powerful terminal emulator.
Run any valid system command directly from the terminal.
> ls -l
> echo Hello, Rust!Implements a built-in cd command to change the current working directory.
> cd src
> cd ..Connect the output of one command to another — just like in real shells.
> ls | grep main
> cat Cargo.toml | grep editionRedirect command output to a file.
> echo Hello > output.txt
> ls > files.txtExit cleanly from the terminal loop.
> exit- Language: Rust 🦀
std::process::Command – to spawn and manage subprocesses
git clone https://github.com/your-username/rust-terminal.git
cd rust-terminalcargo runYou’ll see your custom prompt:
> Start typing commands!
> echo "Rust is awesome!" > message.txt
> cat message.txt
Rust is awesome!
> ls | grep Cargo
Cargo.toml
> cd src
> ls
main.rs
> exit
Goodbye 👋
- The program reads user input in a loop.
- It splits the input into command and arguments.
- Special cases (
cd,exit,|,>) are handled manually. - For all other commands, it uses
Command::new()to spawn subprocesses. - The terminal waits for processes to finish using
.wait().
- How to spawn and pipe processes in Rust.
- How to manipulate I/O streams using
Stdio::piped()andStdio::from(). - How to implement built-in commands like
cdthat modify the current process state. - Building a REPL-like loop with error handling and clean UX.
- Add support for input redirection (
<) - Implement command history
- Handle background processes (
&) - Colorful prompt and formatted output
This project is licensed under the MIT License – feel free to use, modify, and distribute!
Inspired by the UNIX philosophy:
“Write programs that do one thing and do it well.”