Skip to content

S9npai/Katana-Shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Katana Shell

Katana Shell is a POSIX-compliant command line shell for Linux and other UNIX-like systems, built from the ground-up to explore core operating systems concepts and kernel system calls

Inspired by Operating Systems: Three Easy Pieces (OSTEP) 📕

Screenshot

Installation

Prerequisites

  • Linux distribution (Ubuntu, Fedora, etc.. )
  • CMake ≥ 3.20
  • Ninja
  • A C/C++ >= 20 compatible compiler (GCC 13+ or Clang 19+)

Setup & Install

git clone https://github.com/S9npai/Katana-Shell
cd Katana-Shell
cmake -S . -B build -G Ninja
cmake --build build
cmake --install build

This installs:

  • Binary → ~/.local/bin/Katana-Shell
  • Manual → ~/.local/share/Katana-shell/

Note: Make sure ~/.local/bin is in your PATH. If not, add this to your ~/.bashrc or ~/.zshrc: export PATH="$HOME/.local/bin:$PATH"
Then run source ~/.bashrc or source ~/.zshrc to apply

Uninstall: cmake --build build --target uninstall
This removes the binary and the manual directory.
Your history file: ~/.Katana_history is left untouched — delete it manually if needed:


Project Structure

.
├── CMakeLists.txt                  # Build configuration
├── Katana-Shell reference.txt      # User-facing command reference manual
├── README.md
└── src/
    ├── main.cpp                    # Entry point — REPL loop, signal setup, input dispatch
    ├── parser.cpp                  # Tokenizer: parses raw input into Command and pipeline structs
    ├── executor.cpp                # Executes single commands (builtins or external via fork/exec)
    ├── pipeline.cpp                # Handles multi-command pipelines with pipe()/fork()
    ├── signals.cpp                 # Signal handling: parent/child sigaction setup, SIGCHLD blocking
    ├── helpers.cpp                 # Utilities: env var expansion, path expansion
    ├── execindex.cpp               # Builtin command registry (maps names → function pointers)
    ├── redirection.cpp             # I/O redirection handler (<, >, >>, 2>)
    ├── utils.cpp                   # History management (load, save, add, display) + manual display
    ├── commands/
    │   ├── filesys.cpp             # Filesystem builtins: cd, ls, mkdir, rm, cp, mv, etc...
    │   └── sysinfo.cpp             # System info builtins: username, hostname, etc...
    └── include/
        ├── types.hpp               # Core data structures: Command, pipeline, RedirectMode
        ├── parser.hpp
        ├── executor.hpp
        ├── pipeline.hpp
        ├── signals.h
        ├── helpers.hpp
        ├── execindex.hpp
        ├── redirection.hpp
        ├── utils.h
        ├── logo.h                  # ASCII art logo drawn on startup
        ├── commands.h              # Aggregated include for all builtin command headers
        └── cmdheaders/
            ├── filesys.hpp         # Declarations for filesystem builtins
            └── sysinfo.hpp         # Declarations for system info builtins

To-Do

1- Project Setup

  • README guide

2- Core

  • Shell prompt & logo
  • Exit
  • Session hostname & username (whoami + hostname)

3- Commands

  • Command parsing
  • Fork & controlling processes via fork(), execvp() and waitpid()
  • List directory contents (ls)
  • Current directory (pwd)
  • Moving files and directories (mv)
  • Deleting directories (rmdir)
  • File finder (find)
  • File creation and deletion (touch) & (rm)

4- Advanced Features

  • Command pipes ( | )
  • Input/Output Redirection (>, >>, <, <<)
  • Command history

About

The modern UNIX shell — built because I wanted it to exist

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages