Here’s your revised README with the improvements added for clarity, structure, and a touch of personality — great for showcasing your work to employers or online:
This is a custom implementation of a POSIX-compliant shell written in Java. It interprets shell commands, runs external programs, and supports built-in commands like cd, pwd, echo, and more. The shell also supports command parsing, I/O redirection, and autocompletion.
This project is part of the "Build Your Own Shell" Challenge by Codecrafters. It helped me understand how real-world shells like Bash or Zsh work under the hood while sharpening my Java skills.
This Java shell:
- Accepts user input to execute shell commands.
- Implements built-in commands like
cd,pwd,echo,exit, andtype. - Supports running external programs by resolving system
PATH. - Handles input/output/error redirection (e.g.,
>,>>,2>). - Offers command autocompletion using the
Tabkey.
- Java 23
- Maven
- Linux-based system (for POSIX support)
# Clone the repo
git clone https://github.com/Md-Talim/codecrafters-shell-java.git
cd codecrafters-shell-java
# Build the project
mvn clean package
# Run the shell
./your_program.sh- You'll see a prompt like
$ - Enter commands like
pwd,echo Hello,ls, orcd .. - Press
Ctrl + Dto exit
- Built-in Commands:
cd,pwd,echo,exit,type
- External Commands:
- Uses
ProcessBuilderto run commands found in the systemPATH
- Uses
- Redirection:
>,>>, and2>supported
- Autocompletion:
- Pressing
Tabsuggests available commands and executables
- Pressing
- Terminal Control:
- Uses raw input mode for better interactivity
| Component | Responsibility |
|---|---|
Parser.java |
Breaks input into tokens, handles redirection |
Shell.java |
Main shell logic, orchestrates commands |
CommandRegistry |
Registers and manages built-in commands |
ExternalCommand.java |
Executes non-built-in programs via ProcessBuilder |
Redirection.java |
Handles output and error redirection |
AutoCompleter.java |
Suggests commands during typing |
Termios.java |
Enables raw terminal mode via JNA |
- Java 23
- Maven
- JNA (Java Native Access)
- POSIX standards for terminal and process behavior
src/
main/
java/
Main.java # Entry point
shell/
Shell.java # Core shell loop
command/ # Built-in commands
environment/ # Env vars and state
io/ # I/O + redirection
parser/ # Input parsing
process/ # Process execution
terminal/ # Raw mode handling
autocomplete/ # Tab suggestions
- 🧩 Command Parsing: Handling quotes, escapes, and operators
- 🔁 Redirection: Syncing output streams to files accurately
- ⚡ Autocompletion: Real-time feedback and correct suggestions
- 🧠 Terminal Control: Raw mode and disabling echo with JNA
- Internal working of Unix-like shells
- Parsing and interpreting command-line input
- Running processes and managing I/O in Java
- Working with native system APIs using JNA
- Structured thinking and debugging complex workflows
- To understand how Bash/Zsh-like shells work under the hood
- To practice writing clean, modular, and testable Java code
- To solve a real-world systems-level problem from scratch
- To push my boundaries with parsing, process control, and terminal I/O
This project helped me grow as a backend/systems engineer and is one of my favorite learning experiences.
Optional: Add a GIF or screenshot of the shell running in a terminal.
I'm a Computer Science student who loves building things from scratch to deeply understand how they work. I'm currently exploring backend systems, shell design, operating systems, and compilers.
Let me know if you want a shorter version for LinkedIn or a portfolio site too!
