A lightweight, custom shell implementation written in Rust that provides basic Unix command-line functionality.
O-Shell is a minimalist command-line shell built from scratch in Rust. It implements common Unix commands, providing a familiar shell experience while serving as an educational project to understand how shells work under the hood.
- Interactive Shell: Clean, colored prompt showing the current directory
- Built-in Commands: Essential Unix commands implemented in pure Rust
- Lightweight: Minimal dependencies (only
libc) - Cross-platform: Written in Rust for portability
- Rust 1.56 or higher
- Cargo (comes with Rust)
- Clone the repository:
git clone <your-repo-url>
cd 0-shell- Build the project:
cargo build --release- Run the shell:
cargo runOr run the compiled binary directly:
./target/release/O-shell| Command | Description | Flags |
|---|---|---|
echo |
Display a line of text | -n (no trailing newline) |
cd |
Change directory | - |
pwd |
Print working directory | - |
cat |
Concatenate and display files | - |
cp |
Copy files | - |
mv |
Move/rename files | - |
mkdir |
Create directories | - |
exit |
Exit the shell | - |
ls- List directory contents (with-l,-a, and-Fflags)rm- Remove files and directories (with-rflag)
# Print working directory
$ pwd
/home/user
# Change directory
$ cd /tmp
# Create a directory
$ mkdir test_dir
# Display text
$ echo "Hello, World!"
Hello, World!
# Copy a file
$ cp file1.txt file2.txt
# Display file contents
$ cat file.txt
# Move/rename a file
$ mv old_name.txt new_name.txt
# Exit the shell
$ exit0-shell/
├── Cargo.toml # Project configuration
├── src/
│ ├── main.rs # Entry point and REPL
│ └── commands/ # Command implementations
│ ├── mod.rs
│ ├── echo.rs
│ ├── cd.rs
│ ├── ls.rs
│ ├── pwd.rs
│ ├── cat.rs
│ ├── cp.rs
│ ├── rm.rs
│ ├── mv.rs
│ └── mkdir.rs
└── task.md # Development checklist
# Debug build
cargo build
# Release build (optimized)
cargo build --release
# Run tests (if any)
cargo testContributions are welcome! Here are some ways you can contribute:
- Implement missing commands (
ls,rmwith flags) - Add new commands
- Improve error handling
- Add tests
- Improve documentation
This project was created as a learning exercise to better understand:
- How shells work internally
- Systems programming in Rust
- Unix command implementations
- REPL (Read-Eval-Print Loop) design
Note: This is an educational project and not intended to replace production shells like bash or zsh.
⭐ Star this repository if you found it helpful! ⭐
Made with ❤️ from 🇸🇳