Building an IntelliSense-style Shell History Tool in C++20
Source: Dev.to
The Problem: “Search” vs. “Flow”
We all live in our terminals. For years I relied on Ctrl + R or grepping through .zsh_history. Tools like Atuin later revolutionized things with SQLite and syncing, but they didn’t quite fit my workflow.
Most modern history tools act like a search engine: you stop what you’re doing, hit a hotkey, open a full‑screen UI, search for a command, and then execute it. It feels like a context switch.
I wanted something that felt like IntelliSense—something that:
- Predicts what I want as I type.
- Understands my context (e.g., “I’m in a Git repo on the
feature/loginbranch”). - Stays out of my way unless I need it.
So I built BSH (Better Shell History).
Architecture
BSH is a local‑first, latency‑critical shell history manager that hooks into the Zsh Line Editor (ZLE) to provide a predictive overlay updating on every keystroke.
Client‑Daemon Model
| Component | Description |
|---|---|
Daemon (bsh-daemon) | Background process written in C++20. Keeps an open connection to a SQLite database (WAL mode) and an in‑memory cache of Git repository states via libgit2. |
Client (bsh) | Lightweight, ephemeral binary. Serializes each keystroke, sends it over a Unix Domain Socket to the daemon, and prints the response. |
| Interface | Rendered with FTXUI for the TUI overlay. |
Latency is the enemy: a 10 ms delay feels heavy, so the target is.
Try it out and share your thoughts on the “IntelliSense” approach versus the standard search approach!