Loading...

Build your own Shell

Learn about parsing shell commands, executing programs and more

Start Building
shell
TypeScript
shell
C
shell
C++
shell
Elixir
shell
Java
shell
JavaScript
shell
Kotlin
shell
Zig
shell
C#
shell
Go
shell
PHP
shell
Python
shell
Ruby
shell
Rust
shell
Gleam

Build your own Shell is free this November.

The core challenge experience is completely free this month. If you'd like to enjoy advanced features such as running turbo tests, dark mode, or unlimited code examples, you'll need a membership.

A shell is the program that interprets what you type into the terminal. It reads your commands, runs programs, and prints their output. Popular examples are Bash and ZSH.

In this challenge, you'll build your own shell from scratch.

Your shell will run a REPL, parse commands, spawn processes, and more.

What exactly will I build?
What exactly will I learn?
Why should I build such a project?
What are the pre-requisites for this challenge?

Base Stages

A shell is the program that interprets what you type into the terminal. It reads your commands, runs programs, and prints their output. Popular examples are Bash and ZSH.

In this challenge, you'll build your own shell from scratch.

Your shell will run a REPL, parse commands, spawn processes, and more.

Print a prompt
Very easy
We'd expect a proficient developer to take < 5 minutes to complete this stage.
Handle invalid commands
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
Implement a REPL
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Implement exit
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
Implement echo
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Implement type
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Locate executable files
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Run a program
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.

Navigation

In this challenge extension, you'll add directory navigation support by implementing the cd and pwd commands.

Along the way, you'll learn about what the "current working directory" is, how to change it and more.

The pwd builtin
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
The cd builtin: Absolute paths
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
The cd builtin: Relative paths
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
The cd builtin: Home directory
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.

Quoting

In this challenge extension, you'll add quoting support to your shell.

Quoting allows you to preserve whitespace and special characters in your shell commands.

Single quotes
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Double quotes
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Backslash outside quotes
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Backslash within single quotes
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Backslash within double quotes
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Executing a quoted executable
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.

Redirection

In this challenge extension, you'll add redirection support to your shell.

Redirection allows you to redirect the output of a command to a file or another command.

Redirect stdout
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Redirect stderr
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Append stdout
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Append stderr
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.

Autocompletion

In this challenge extension, you'll add programmable completion support to your shell.

Programmable completion allows you to autocomplete commands and executable files.

Builtin completion
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Completion with arguments
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Missing completions
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
Executable completion
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Multiple completions
Hard
We'd expect a proficient developer to take more than 1 hour to complete this stage.
Partial completions
Hard
We'd expect a proficient developer to take more than 1 hour to complete this stage.

Pipelines

In this challenge extension, you'll add support for pipelines to your shell.

Pipelines allow you to connect multiple commands together, so the output of one command becomes the input of the next command.

Dual-command pipeline
Hard
We'd expect a proficient developer to take more than 1 hour to complete this stage.
Pipelines with built-ins
Hard
We'd expect a proficient developer to take more than 1 hour to complete this stage.
Multi-command pipelines
Hard
We'd expect a proficient developer to take more than 1 hour to complete this stage.

History

In this challenge extension, you'll add support for viewing and recalling previously entered commands using the history builtin.

History allows you to view and recall previously entered commands. Also, use it to re-run previous commands using the UP and DOWN arrow keys.

The history builtin
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
Listing history
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Limiting history entries
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Up-arrow navigation
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Down-arrow navigation
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Executing commands from history
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.

History Persistence

In this challenge extension, you'll add support for persisting history to a file.

History persistence allows you to save and load previously entered commands to and from a file.

Read history from file
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Write history to file
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Append history to file
Hard
We'd expect a proficient developer to take more than 1 hour to complete this stage.
Read history on startup
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
Write history on exit
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
Append history on exit
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.