Skip to content

Mini Shell – A Unix-like command-line shell implemented in C with support for built-in and external commands, dynamic prompt showing current directory, pipes, and signal handling.

Notifications You must be signed in to change notification settings

Pankajvishw/Minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini Shell (Unix-like Shell Implementation in C)

Overview

Mini Shell is a lightweight Unix-like command-line interpreter implemented in C. It supports execution of built-in and external commands, piping, signal handling, and a dynamic prompt that displays the current working directory.

This project was developed as part of advanced C and Linux systems programming practice.

Features

  • Custom shell prompt (minishell:)
  • Dynamic prompt showing current working directory
  • Built-in commands (cd, pwd, echo, exit, etc.)
  • Execution of external commands using fork() and execvp()
  • Pipe (|) support
  • Signal handling (SIGINT, SIGTSTP)
  • Process synchronization using wait()
  • Input parsing and error handling

Technologies Used

  • C Programming
  • Linux System Calls
  • Process Management
  • Signals
  • File Descriptors and Pipes

Project Structure

minishell/
├── *.c
├── *.h
├── src/
│   ├── *.o
├── Makefile
├── README.md
└── .gitignore

How the Prompt Works

The shell prompt is constructed by concatenating a static identifier (minishell:) with the current working directory.

To optimize performance, the prompt is initialized before the main loop and updated only when the directory changes, i.e., after a successful cd command. This avoids unnecessary getcwd() calls on every iteration while keeping the prompt accurate.

How to Build

make

How to Run

./minishell

Sample Usage

minishell:/home/pankaj$ pwd
/home/pankaj
minishell:/home/pankaj$ cd projects
minishell:/home/pankaj/projects$ ls | grep shell

minishell:/home/pankaj/projects$ echo Hello World
Hello World

Learning Outcomes

  • Understanding how Unix shells interpret and execute commands
  • Hands-on experience with fork(), execvp(), and wait()
  • Practical implementation of pipes and signal handling
  • Improved modular programming and debugging skills
  • Exposure to real-world Linux system programming concepts

Author

Pankaj Kumar B.Tech – Electronics & Communication Engineering, Embedded Systems and Linux Programming Enthusiast

About

Mini Shell – A Unix-like command-line shell implemented in C with support for built-in and external commands, dynamic prompt showing current directory, pipes, and signal handling.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published