Skip to content

Sudhanshu-Ambastha/Mini-Shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini-Shell

A minimalist, high-performance shell implemented in C++, featuring a native C process executor and a Python-embedded CLI interface. This project demonstrates Hybrid Systems Architecture: combining low-level C memory management with high-level Python metadata visualization.

🚀 Overview

Mini-Shell utilizes a Layered Architecture:

  • Command Dispatcher (C): A centralized logic hub (ui_actions.c) that separates "Built-in" commands (Help, Stats, Clear) from "External" system commands.
  • Native Executor (C++): Manages process lifecycles using _spawnvp (Windows) or fork/exec (POSIX), bypassing insecure system() calls for external binaries.
  • Embedded Python Bridge: A zero-latency bridge that reloads Python UI modules at runtime, allowing for "Hot-Swapping" the interface without restarting the shell.
  • Dynamic Build Pipeline: A PowerShell-driven CI/CD script that automatically discovers source files and resolves Python headers dynamically from the local virtual environment.

📂 Project Structure

Mini-Shell/
├── build/                # Compiled binary output
├── deps/                 # Third-party dependency headers
├── include/              # Header files (.h, .hpp)
├── scripts/
│   └── run.ps1           # Dynamic build audit & launch script
├── src/                  # Implementation (main.cpp, pybridge.c, ui_actions.c)
├── ui/                   # Python UI logic (rich_ui.py)
└── mysys_venv/           # Isolated Python environment

🛠️ Installation & Setup

1. Automated Environment Setup

Mini-Shell handles its own dependency management. It automatically detects, creates, and configures a local virtual environment (mysys_venv) based on the root requirements.txt.

2. Python Dependencies

Ensure your requirements.txt contains the necessary UI libraries:

rich

🏗️ Building and Running

The project features an Atomic Build Pipeline. The run.ps1 script performs a full build audit, resolves Python headers dynamically from your venv, and compiles all source modules in a single pass.

./scripts/run.ps1
  • Compiler: g++ (MinGW-w64)
  • Dynamic Discovery: Automatically locates and compiles all .c and .cpp files within the src/ directory
  • Python Bridge: Dynamically links against the specific Python interpreter version found in the local environment (e.g., python313)
  • Static Linking: Utilizes -static-libgcc and -static-libstdc++ to ensure the binary remains portable across Windows environments

🛡️ Execution Architecture

  • Command Dispatcher: Internal commands (help, stats, cls) are intercepted by a central dispatcher in ui_actions.c, which orchestrates the Embedded Python Bridge

  • Native Execution Logic: For external system commands, the shell bypasses the insecure system() wrapper. Instead, it utilizes a native C++ executor that leverages _spawnvp (Windows) to manage child process lifecycles and parent-wait states directly

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A modular hybrid-systems shell implemented in C++, featuring native process orchestration via _spawnvp, a centralized C command dispatcher, and an embedded Python bridge for high-fidelity CLI visualization using Rich.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors