cd /news/ai-tools/smart-terminal-zsh-ghost-text-comman… · home › topics › ai-tools › article
[ARTICLE · art-177736] src=github.com ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

Smart-terminal – zsh ghost-text command suggestions with reversibility

A Rust-built shell companion called smart-terminal, or next-cmd, adds zsh ghost-text command suggestions that predict the next command from the current directory, recent shell history and partial prompts, using provider-specific LLMs through Groq, OpenRouter and Google Gemini. Each suggestion carries a one-line explanation and a color-coded reversibility flag across five levels, from Full (green, read-only commands such as ls and git log) to Irreversible (dark red, such as rm -rf and git push --force), and nothing executes without the user pressing ^F to accept, ^G to fetch or ^B to clear. The tool also scopes memory per folder via smart-terminal memory init, show, clear and delete, and offers an investigate command in which a planner agent forms a plan and an executor agent runs it against the filesystem and shell, resuming a saved Google Gemini session by default unless --one-off is passed.

key takeaway

smart-terminal's next-cmd inserts only the suggested command into the editable buffer on ^F, keeping the explanation as display-only ghost text, and tags each suggestion with one of five reversibility levels from Full to Irreversible.

read6 min views5 publishedNov 28, 2026
Smart-terminal – zsh ghost-text command suggestions with reversibility
Image: Michielbdejong (auto-discovered)

An AI-powered shell companion that predicts your next command and investigates your codebase and shell environment.

Built in Rust. Uses provider-specific LLMs via Groq, OpenRouter, and Google Gemini.

The project docs are split into a few focused guides:

Shell users at every level — beginners learning the ropes, intermediates getting better, and professionals who already know their tools and want to move faster.

Every prediction comes with a one-line explanation and a reversibility flag. Nothing runs without your keystroke.

Not a chat box that wraps the terminal. A completion layer that respects it.

The following demo shows next-cmd reacting to real shell context while working through a small Git workflow.

The model infers intent from:

  • the current directory
  • recent shell history
  • partial commands and ambiguous prompts

Notice how suggestions stay context-aware while remaining fast enough to feel native to the terminal experience.

Screen.Recording.2026-07-02.at.6.29.06.PM.mov #

Press ^G to fetch a suggestion, ^F to accept, ^B to clear.

Suggestions may contain multiple lines, including shell blocks and here-documents. ^F inserts only the suggested command into the editable buffer; the explanation stays as display-only ghost text and is not added to the command.

The inline # description next to each suggestion is color-coded by how reversible the predicted command is — at a glance you know the cost of pressing ^F

Note

These levels are intentionally approximate — they are not strict safety guarantees.

They exist to provide a quick intuition about the potential impact and reversibility of a command, so the color alone gives the user an immediate signal about how careful they should be before pressing ^F.

Level Color Meaning Example
Full 🟢 read-only or fully reversible ls ,grep ,git log
Mostly 🔵 undoable in one step git stash ,git commit
Partial 🟡 some effects stick mkdir ,touch ,git add
Hard 🔴 requires manual cleanup git switch ,docker system prune
Irreversible 🟥 cannot be undone rm -rf ,git push --force

Memory is scoped per folder. When registered, next-cmd reads prior interactions in this project and feeds them back into the model, so suggestions sharpen over time.

$ smart-terminal memory init
✓ registered /home/jsn/projects/smart-terminal
 
$ smart-terminal memory show
memory for /home/jsn/projects/smart-terminal (2 interactions):
 
  1. git st → git status
  2. cargo t → cargo test --workspace
 
$ smart-terminal memory clear
✓ cleared interactions for /home/jsn/projects/smart-terminal
 
$ smart-terminal memory delete
✓ deleted memory for /home/jsn/projects/smart-terminal

Pose a question; a planner agent forms a plan, an executor agent runs it against your filesystem and shell, and you get a grounded answer.

Investigation resumes the project's saved session by default (using Google Gemini). Use --one-off to run without or saving history, or sterm ask as a shorter alias:

$ smart-terminal investigate --one-off "What does this repository do?"
$ sterm ask "Why is this test failing?"
$ smart-terminal investigate session clear

Screen.Recording.2026-05-30.at.1.41.15.PM.mov #

Every investigation also suggests a follow-up command (shown as ghost text with the Zsh integration, or printed after the report). Useful for exploring unfamiliar codebases, checking git state, debugging failing tests, or comparing branches.

Note

investigate chains multiple Gemini calls per run, while next-cmd uses Groq. If you hit a provider rate limit, wait a few seconds and retry. For Zsh integration internals and session/scratchpad details, see docs/architecture.md.

smart-terminal separates terminal presentation (src/cli), agent reasoning ( src/agent), background job execution ( src/multithreading), LLM providers ( src/providers), persistence ( src/persistence), and system tools ( src/tools) behind provider-agnostic contracts in src/core.

Command Workflow Provider
next-cmd Single cmd_predictor agent (ReactLoop ) Groq
investigate (ask ) planner →executor (ReactLoop ) Google Gemini

Full layer breakdown, provider codec details (groq, openrouter, google), and extension points live in docs/architecture.md.

  • Modular — Clear separation between interface, reasoning, tooling, and provider logic.
  • Pluggable — New agent architectures and LLM providers can be added easily.
  • Stateful — Persistent JSON memory enables cross-session continuity.
  • Testable — Integration tests validate real workflow execution end-to-end.

Requirements: macOS or Linux with zsh and Rust installed.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"

If Rust is already installed, source "$HOME/.cargo/env" is enough to add Cargo to your PATH in the current shell.

smart-terminal uses Groq for command prediction, and the investigate feature uses Gemini/Google.

  • Create a Groq key at console.groq.com
  • Create a Google/Gemini key in the relevant Google AI console if you plan to use smart-terminal investigate

Add them to your shell profile so the app can read them at runtime:

cat <<'EOF' >> ~/.zshrc
export GROQ_API_KEY="your_groq_api_key"
export GEMINI_API_KEY="your_gemini_api_key"
EOF
source ~/.zshrc
git clone https://github.com/sdi2200246/smart-terminal.git
cd smart-terminal
cargo install --path .

This builds the Rust binary and installs it to ~/.cargo/bin, which is already on your PATH via rustup.

The shell hook lives in scripts/zsh/smart-terminal.zsh.

cat <<'EOF' >> ~/.zshrc
source /path/to/smart-terminal/scripts/zsh/smart-terminal.zsh
reload() { source ~/.zshrc; }
EOF
source ~/.zshrc

Replace /path/to/smart-terminal with the actual location where you cloned the repo.

smart-terminal next-cmd "list files"

You should see a command suggestion printed. Then open a fresh zsh session and press ^G on an empty prompt — the ghost suggestion should appear inline. If it does, setup is complete.

Pull the latest changes, rebuild the binary, and reload the zsh integration:

cd /path/to/smart-terminal
git pull
cargo install --path . --force
reload

--force replaces the existing binary in ~/.cargo/bin, and reload re-sources your zsh config so the latest hook is active.

Other open terminal tabs keep the old shell integration until you run reload in them or open a fresh session.

  • Folder-scoped investigation state — maintain one investigation conversation history per project folder, so theinvestigate agent can preserve context between sessions without mixing unrelated projects.
  • Conversation management commands — add commands to inspect or erase the stored investigation history when users want to start fresh.
  • Alternative shell integrations — native support for Fish, Bash, and Nushell.
  • Offline / Local LLM support — first-class integration with Ollama andllama.cpp .

Contributions, bug reports, and feature suggestions are warmly welcomed! 🎉

As the original author is stepping back from active development, the project is wide open for community direction, experiments, and new co-maintainers. If you're interested in shaping an AI shell companion in Rust, we'd love to have you.

Check out CONTRIBUTING.md to get started with:

  • Local setup & testing guidelines
  • High-impact areas needing help (shells, providers, tools, performance)
  • Code conventions and PR submission workflow
  • Co-maintainership and stewardship opportunities

Built with 🦀 by Jason Stefanou

Informatics Undergraduate at the National and Kapodistrian University of Athens.

Questions, setup issues, bug reports, and improvement ideas are always welcome.

If something breaks, feels unclear, or you have suggestions for new features or workflow improvements, feel free to open an issue or reach out directly.

── more in #ai-tools 4 stories · sorted by recency
── more on @smart-terminal 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/smart-terminal-zsh-g…] indexed:0 read:6min 2026-11-28 · —