A small yet powerful Unix-like shell written in C, featuring interactive command line editing, job control, aliases, and more.
- Interactive Command Line: Full readline support with history, tab completion, and line editing
- Job Control: Background job management with
jobs,fg, andbgcommands - Alias Support: Command aliases with
aliasandunalias - Built-in Commands:
cd,pwd,exit,help,jobs,fg,alias,unalias - Redirection: Input/output redirection with
>,>>,< - Pipelines: Command chaining with
| - Signal Handling: Proper Ctrl+C handling
- Cross-Platform: Works on macOS, Linux, FreeBSD, OpenBSD, and NetBSD
| Platform | Package Manager | Dependencies |
|---|---|---|
| Ubuntu/Debian | apt |
build-essential libreadline-dev |
| CentOS/RHEL | yum |
Development Tools readline-devel |
| Fedora | dnf |
Development Tools readline-devel |
| Arch Linux | pacman |
base-devel readline |
| macOS | brew |
readline |
| FreeBSD | pkg |
gcc readline |
| OpenBSD | pkg_add |
gcc readline |
| NetBSD | pkgin |
gcc readline |
# Clone the repository
git clone <repository-url>
cd ccsh-shell
# Install dependencies and build
./build-and-package.sh -a# 1. Install dependencies (see platform-specific instructions below)
# 2. Build the project
make all
# 3. Run the shell
./ccshsudo apt update
sudo apt install build-essential libreadline-dev# CentOS/RHEL
sudo yum groupinstall "Development Tools"
sudo yum install readline-devel
# Fedora
sudo dnf groupinstall "Development Tools"
sudo dnf install readline-develsudo pacman -S --needed base-devel readline# Install Homebrew (if not already installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install dependencies
brew install readlinesudo pkg install gcc readlinesudo pkg_add gcc readlinesudo pkgin install gcc readline# Standard build
make all
# Static binary (Linux/BSD)
make static
# Debug build
make debug
# Clean build artifacts
make clean
# Check dependencies
make check-deps
# Show help
make help# Full automated build (install deps + build + test + package)
./build-and-package.sh -a
# Install dependencies only
./build-and-package.sh -d
# Check dependencies
./build-and-package.sh -c
# Build specific type
./build-and-package.sh -b normal # Standard build
./build-and-package.sh -b static # Static binary
./build-and-package.sh -b debug # Debug build
# Test the build
./build-and-package.sh -t
# Create distribution package
./build-and-package.sh -p
# Build and package
./build-and-package.sh -b normal -pThe build script can create a distribution package with all necessary files:
# Create distribution package
./build-and-package.sh -pThis creates a dist/ folder with:
- Compiled executable
- Installation/uninstallation scripts
- Documentation
- Test scripts
- Compressed tar.gz package with checksum
# Start the shell
./ccsh
# Run a command and exit
echo "ls" | ./ccshccsh> help # Show help
ccsh> cd /tmp # Change directory
ccsh> pwd # Print working directory
ccsh> jobs # List background jobs
ccsh> alias ll=ls # Create alias
ccsh> unalias ll # Remove alias
ccsh> exit # Exit shellccsh> sleep 10 & # Run in background
ccsh> jobs # List background jobs
ccsh> fg 0 # Bring job to foregroundccsh> ls > files.txt # Output redirection
ccsh> cat < files.txt # Input redirection
ccsh> ls | grep .c # Pipeline
ccsh> echo "test" >> log # Append redirectionccsh-shell/
├── main.c # Main shell implementation
├── Makefile # Cross-platform build configuration
├── build-and-package.sh # Automated build script
├── test.sh # Test suite
├── README.md # This file
└── docs/ # Documentation
The build system automatically detects your platform and configures the appropriate compiler flags and libraries:
- Linux: Uses
-lreadline -lncurses -ltinfofor static builds - macOS: Uses
-lreadline(static linking limited) - BSD: Uses
-lreadline -lncursesfor static builds
# Build with debug symbols
make debug
# Run with debug output
./ccsh# Run the test suite
make test
# Or use the build script
./build-and-package.sh -t-
"readline/readline.h: No such file or directory"
- Install readline development headers for your platform
- Use
./build-and-package.sh -dto install dependencies
-
Static linking fails on macOS
- macOS has limitations with static linking
- Use
make allinstead ofmake static
-
Build fails on unknown Linux distribution
- Install manually:
gcc,make,readline-dev - Or use the build script:
./build-and-package.sh -d
- Install manually:
- macOS: Static linking is limited due to system restrictions
- FreeBSD: May require additional ncurses libraries
- OpenBSD: Uses different package manager (
pkg_add) - NetBSD: Uses
pkginpackage manager
- Fork the repository
- Create a feature branch
- Make your changes
- Test on multiple platforms
- Submit a pull request
- GNU Readline library for interactive command line editing
- POSIX standards for shell compatibility
If you find my work useful, consider supporting it: