A fully-featured command-line shell written in pure C with no external dependencies. Implements core Unix shell features on Windows.
- Command Execution - Run any Windows executable or batch file
- Pipeline Support - Chain commands with
|(e.g.,ls | grep txt) - I/O Redirection - Input
<, output>, append>> - Background Jobs - Run commands in background with
&
| Category | Commands |
|---|---|
| Navigation | cd, pwd, ls (with -a, -l flags) |
| File Ops | cat, touch, mkdir, rmdir, rm, cp, mv |
| Shell | echo, alias, unalias, history, export, env |
| System | whoami, hostname, date, time, which, clear |
| Control | exit, help, version |
- Command History - Persistent history saved to
~/.cshell_history - Aliases - Create shortcuts (e.g.,
alias ll="ls -l") - Variable Expansion -
$VAR,${VAR},$?(exit code),$$(PID) - Home Directory -
~expands to user profile - Color Output - Syntax highlighting for prompts, errors, and
ls
CShell/
├── include/
│ └── shell.h # Core header with all definitions
├── src/
│ ├── main.c # Entry point
│ ├── shell.c # Shell initialization and main loop
│ ├── parser.c # Command parsing and tokenization
│ ├── builtins.c # Built-in command implementations
│ ├── executor.c # External command and pipeline execution
│ ├── history.c # Command history management
│ ├── utils.c # Utility functions (colors, prompts, etc.)
│ ├── alias.c # Alias management
│ └── env.c # Environment variable handling
├── CMakeLists.txt # Build configuration
├── LICENSE # MIT License
└── README.md
- GCC (MinGW-w64 on Windows) or MSVC
- CMake 3.11+
# Create build directory
mkdir build && cd build
# Configure
cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release ..
# Build
cmake --build .
# Run
./cshellgcc -std=c11 -O2 -Wall -Iinclude src/*.c -o cshell.exe./cshell./cshell script.sh╔═══════════════════════════════════════════════════════╗
║ CShell - Custom Command Line Shell ║
║ Version 1.0.0 ║
║ Type 'help' for available commands ║
╚═══════════════════════════════════════════════════════╝
user@DESKTOP:~/projects $ ls -l
drwxr-xr-x <DIR> 2026-01-13 03:30 CShell/
-rw-r--r-- 1.2K 2026-01-13 03:25 README.md
user@DESKTOP:~/projects $ cd CShell
user@DESKTOP:~/projects/CShell $ cat README.md | head
user@DESKTOP:~/projects/CShell $ alias ll="ls -l"
user@DESKTOP:~/projects/CShell $ ll > files.txt
user@DESKTOP:~/projects/CShell $ history 5
1 12:30 ls -l
2 12:30 cd CShell
3 12:31 cat README.md | head
4 12:31 alias ll="ls -l"
5 12:31 ll > files.txt
user@DESKTOP:~/projects/CShell $ exit
-
Systems Programming
- Process creation with
CreateProcess()Windows API - Handle inheritance for I/O redirection
- Signal handling and process management
- Process creation with
-
Data Structures
- Doubly linked list for command history
- Dynamic arrays for tokenization
- Hash-like structures for aliases and environment
-
Parsing & Compilation Concepts
- Lexical analysis (tokenization)
- Syntax parsing (command structure)
- Variable expansion and substitution
-
Memory Management
- Manual allocation/deallocation
- No memory leaks (Valgrind clean equivalent)
- Proper cleanup on exit
-
Software Architecture
- Modular design (separate concerns)
- Clean API between components
- Extensible command system
- Tab completion
- Command line editing (arrow keys)
- Job control (
fg,bg,jobs) - Scripting (if/else, loops, functions)
- Glob patterns (
*.txt,file?) - Configuration file (
.cshellrc)
MIT License - See LICENSE
Author: Shiva Kar
Built with: Pure C (C11) - No external dependencies
Lines of Code: 2000+
A real systems programming project demonstrating low-level C skills.