A custom Unix-like shell built in C, supporting command execution, foreground/background process handling, piping, redirection, shell logging, and modular built-in utilities.
This project implements a lightweight Unix-like shell from scratch with a focus on:
- command parsing and execution
- foreground and background process handling
- piping and I/O redirection
- shell prompt rendering
- persistent command logging
- custom built-in commands
- shell customization through rc-style configuration
The shell is organized modularly so that parsing, execution, prompting, logging, and built-ins are separated across source files.
- interactive shell prompt
- execution of standard Unix commands
- foreground and background process support
- signal-aware shell behavior
- modular command dispatch architecture
- command parsing and tokenization
- piping support
- input redirection (
<) - output overwrite redirection (
>) - output append redirection (
>>)
seek— file and directory search utilityproclore— process inspection utilityneonate— monitoring utilityiman— custom manual/help command- shell logging support
- shell rc configuration via
myshrc
.
├── Makefile
├── readme.md
└── src
├── main.c
├── prompt.c / prompt.h
├── inputhandler.c / inputhandler.h
├── commandhandler.c / commandhandler.h
├── color.c / color.h
├── log.c / log.h
├── proclore.c / proclore.h
├── seek.c / seek.h
├── myshrc.c / myshrc.h
├── neonate.c / neonate.h
└── iman.c / iman.h
You need:
gccmakelibcurldevelopment package
sudo apt update
sudo apt install build-essential libcurl4-openssl-devsudo dnf install gcc make libcurl-develsudo pacman -S base-devel curlClone the repository:
git clone https://github.com/garimamittal13/C-shell.git
cd C-shellBuild the shell:
makeThis creates the executable:
./my_shellAfter building the project, start the shell by running:
./my_shellYou should now see the custom shell prompt and can start typing commands.
./my_shell
pwd
ls
echo hellosleep 10 &ls | wc
cat file.txt | grep helloecho hello > out.txt
sort < input.txt
cat file.txt >> log.txtseek filename
proclore
neonate
iman seekTo remove object files and the compiled executable:
make clean- Modular architecture: parsing, execution, prompting, logging, and built-ins are implemented as separate modules.
- Extensible built-ins: custom shell commands are isolated cleanly, making the shell easier to extend.
- Systems programming focus: emphasizes process handling, pipes, redirection, and shell control flow in C.
Through this project, I explored:
- Unix process creation and execution
- shell command parsing
- pipes and file descriptor redirection
- modular systems programming in C
- implementation of custom shell utilities
- integrating external libraries like
libcurl
- Language: C
- Build System: Makefile
- Concepts: operating systems, processes, pipes, redirection, shell design, modular programming
Potential extensions include:
- command history navigation
- tab completion
- improved job control
- aliases and environment variable expansion
- more built-in shell utilities