shellx_
a unix shell, built from scratch

ShellX

A minimal POSIX shell written from first principles in C — spawning and waiting on real processes with fork(), exec() and waitpid(). Built-in cd, pwd and exit, plus anything else on your $PATH.

akshat@localhost — shellx
$ ./shellx
shellx> pwd
/home/akshat
shellx> ls
projects notes Downloads
shellx> #projects # fuzzy history search
shellx> cd projects # recalled from history
shellx> exit
shellx>
the x factor

More than fork-and-exec: a shell that remembers.

Most from-scratch shells stop once a command runs. ShellX also treats history as a first-class feature — searchable, durable, and interruptible without ever taking the shell down with it.

Fuzzy #keyword history search

Type # followed by any fragment of a past command and ShellX scans its history for the most recent match — no scrolling, no retyping. #proj instantly recalls cd projects from ten commands ago.

Arrow-key recall, via readline

ShellX links against GNU readline, so the up and down arrows walk backward and forward through everything you have typed in the session, with normal line-editing (Ctrl+A/E, word-delete) for free.

Every command, timestamped, on disk

Each line you run is appended to ~/.shellx_history.txt with a timestamp the moment it executes, so your shell history survives restarts and doubles as an audit log.

Ctrl+C that respects the shell

ShellX installs its own SIGINT handler. Pressing Ctrl+C interrupts whatever child process is running in the foreground — it never kills the shell itself, matching how bash and zsh behave.

key concepts
fork()execvp()waitpid()POSIXC99tokenizerGNU readlineSIGINT handlerhistory persistence
run it

One file, one compiler flag.

# build
$ gcc shellx.c -o shellx -lreadline
# run
$ ./shellx

Dependency: readline

ShellX links against GNU readline for arrow-key history recall and line editing.

macOS brew install readline
Debian/Ubuntu apt install libreadline-dev

Platform

Built on POSIX APIs (fork, exec, waitpid, signal), so it compiles and runs on Linux and macOS. No Windows support — there is no POSIX process model to build on there.