Personal project to learn and practice C by building a custom interactive shell.
cline is a simple shell (command interpreter) written in C, created as an educational tool to get hands-on experience with core concepts of the C language and system programming.
This project simulates a simplified Unix/Linux console, allowing command execution, directory changes, and exiting with the exit command. It is designed to be cross-platform, working on both Linux/WSL and Windows (MinGW/MSYS2), adapting execution based on the operating system.
- Dynamic prompt showing username, hostname, and current directory with ANSI colors.
- Support for built-in commands:
cdto change directories.exitto quit the shell.
- Execution of external commands via
execvp(Linux) orsystem()(Windows). - Simple input tokenization.
- Basic error handling and input cleanup.
- Pure C language.
- POSIX APIs for Linux/Unix.
- Adapted functions for Windows compatibility.
- Makefile for easy compilation.
This project is a starting point and has plenty of room to grow. Some ideas for upcoming versions include:
- Command history: save and navigate through previous commands with arrow keys.
- Command and path autocompletion.
- Input/output redirection (
>,<,>>). - Pipes (
|) to chain commands. - Custom environment variables support.
- Background process handling.
- Better signal handling (Ctrl+C, Ctrl+Z).
- Graphical interface or improved integration with modern terminals.
- Code modularization and cleanup for easier extension.
On a compatible terminal (Linux, WSL, MinGW/MSYS2):
make
./clineOn Windows, the executable will be cline.exe and can be run directly from the command prompt.
This project is mainly for personal learning, but if you'd like to contribute ideas or improvements, pull requests and suggestions are very welcome!
MIT License © Aleix
Thanks for checking out this project! I hope cline is as useful to you as it has been for my C and systems programming learning journey.