Skip to content

A lightweight Unix-like shell implementation in Rust with built-in commands (echo, cd, pwd, cat, cp, mv, mkdir). Educational project for learning systems programming and shell internals.

Notifications You must be signed in to change notification settings

TanakAiko/0-shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

O-Shell

Rust Linux Shell

A lightweight, custom shell implementation written in Rust that provides basic Unix command-line functionality.

📖 Overview

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.

✨ Features

  • 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

🚀 Getting Started

Prerequisites

  • Rust 1.56 or higher
  • Cargo (comes with Rust)

Installation

  1. Clone the repository:
git clone <your-repo-url>
cd 0-shell
  1. Build the project:
cargo build --release
  1. Run the shell:
cargo run

Or run the compiled binary directly:

./target/release/O-shell

📝 Supported Commands

Implemented Commands

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 -

In Development

  • ls - List directory contents (with -l, -a, and -F flags)
  • rm - Remove files and directories (with -r flag)

💡 Usage Examples

# 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
$ exit

🛠️ Development

Project Structure

0-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

Building from Source

# Debug build
cargo build

# Release build (optimized)
cargo build --release

# Run tests (if any)
cargo test

🤝 Contributing

Contributions are welcome! Here are some ways you can contribute:

  • Implement missing commands (ls, rm with flags)
  • Add new commands
  • Improve error handling
  • Add tests
  • Improve documentation

🙏 Acknowledgments

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 🇸🇳

About

A lightweight Unix-like shell implementation in Rust with built-in commands (echo, cd, pwd, cat, cp, mv, mkdir). Educational project for learning systems programming and shell internals.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages