{"slug": "smart-terminal-zsh-ghost-text-command-suggestions-with-reversibility", "title": "Smart-terminal – zsh ghost-text command suggestions with reversibility", "summary": "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.", "body_md": "An AI-powered shell companion that predicts your next command and investigates your codebase and shell environment.\n\nBuilt in Rust. Uses provider-specific LLMs via Groq, OpenRouter, and Google Gemini.\n\nThe project docs are split into a few focused guides:\n\n- [CONTRIBUTING.md](https://github.com/sdi2200246/smart-terminal/blob/main/CONTRIBUTING.md) — guide for contributors, open ideas, and maintainership opportunities.\n- [docs/architecture.md](https://github.com/sdi2200246/smart-terminal/blob/main/docs/architecture.md) — architecture, data flow, and extension points.\n- [docs/development.md](https://github.com/sdi2200246/smart-terminal/blob/main/docs/development.md) — local setup, build/test workflow, and contributor expectations.\n\nShell users at every level — beginners learning the ropes, intermediates getting better, and professionals who already know their tools and want to move faster.\n\nEvery prediction comes with a one-line explanation and a reversibility flag. Nothing runs without your keystroke.\n\nNot a chat box that wraps the terminal. A completion layer that respects it.\n\nThe following demo shows `next-cmd` reacting to real shell context while working through a small Git workflow.\n\nThe model infers intent from:\n\n- the current directory\n- recent shell history\n- partial commands and ambiguous prompts\n\nNotice how suggestions stay context-aware while remaining fast enough to feel native to the terminal experience.\n\n## Screen.Recording.2026-07-02.at.6.29.06.PM.mov\n\nPress `^G` to fetch a suggestion, `^F` to accept, `^B` to clear.\n\nSuggestions may contain multiple lines, including shell blocks and here-documents.\n`^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.\n\nThe 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\n\nNote\n\nThese levels are intentionally approximate — they are not strict safety guarantees.\n\nThey 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`.\n\n| Level | Color | Meaning | Example | \n|---|---|---|---|\n| **Full** | 🟢 | read-only or fully reversible | `ls` ,`grep` ,`git log` | \n| **Mostly** | 🔵 | undoable in one step | `git stash` ,`git commit` | \n| **Partial** | 🟡 | some effects stick | `mkdir` ,`touch` ,`git add` | \n| **Hard** | 🔴 | requires manual cleanup | `git switch` ,`docker system prune` | \n| **Irreversible** | 🟥 | cannot be undone | `rm -rf` ,`git push --force` | \n\nMemory 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.\n\n``` bash\n$ smart-terminal memory init\n✓ registered /home/jsn/projects/smart-terminal\n \n$ smart-terminal memory show\nmemory for /home/jsn/projects/smart-terminal (2 interactions):\n \n  1. git st → git status\n  2. cargo t → cargo test --workspace\n \n$ smart-terminal memory clear\n✓ cleared interactions for /home/jsn/projects/smart-terminal\n \n$ smart-terminal memory delete\n✓ deleted memory for /home/jsn/projects/smart-terminal\n```\n\nPose a question; a planner agent forms a plan, an executor agent runs it against your filesystem and shell, and you get a grounded answer.\n\nInvestigation resumes the project's saved session by default (using Google Gemini). Use `--one-off` to run without loading or saving history, or `sterm ask` as a shorter alias:\n\n``` bash\n$ smart-terminal investigate --one-off \"What does this repository do?\"\n$ sterm ask \"Why is this test failing?\"\n$ smart-terminal investigate session clear\n```\n\n## Screen.Recording.2026-05-30.at.1.41.15.PM.mov\n\nEvery 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.\n\nNote\n\n`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.\nFor Zsh integration internals and session/scratchpad details, see [docs/architecture.md](https://github.com/sdi2200246/smart-terminal/blob/main/docs/architecture.md).\n\n`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`.\n\n| Command | Workflow | Provider | \n|---|---|---|\n| `next-cmd` | Single `cmd_predictor` agent (`ReactLoop` ) | Groq | \n| `investigate` (`ask` ) | `planner` →`executor` (`ReactLoop` ) | Google Gemini | \n\nFull layer breakdown, provider codec details (`groq`, `openrouter`, `google`), and extension points live in [docs/architecture.md](https://github.com/sdi2200246/smart-terminal/blob/main/docs/architecture.md).\n\n- **Modular** — Clear separation between interface, reasoning, tooling, and provider logic.\n- **Pluggable** — New agent architectures and LLM providers can be added easily.\n- **Stateful** — Persistent JSON memory enables cross-session continuity.\n- **Testable** — Integration tests validate real workflow execution end-to-end.\n\n**Requirements**: macOS or Linux with **zsh** and Rust installed.\n\n```\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\nsource \"$HOME/.cargo/env\"\n```\n\nIf Rust is already installed, `source \"$HOME/.cargo/env\"` is enough to add Cargo to your `PATH` in the current shell.\n\n`smart-terminal` uses Groq for command prediction, and the `investigate` feature uses Gemini/Google.\n\n- Create a Groq key at [console.groq.com](https://console.groq.com)\n- Create a Google/Gemini key in the relevant Google AI console if you plan to use `smart-terminal investigate`\n\nAdd them to your shell profile so the app can read them at runtime:\n\n```\ncat <<'EOF' >> ~/.zshrc\nexport GROQ_API_KEY=\"your_groq_api_key\"\nexport GEMINI_API_KEY=\"your_gemini_api_key\"\n# or: export GOOGLE_API_KEY=\"your_gemini_api_key\"\nEOF\nsource ~/.zshrc\ngit clone https://github.com/sdi2200246/smart-terminal.git\ncd smart-terminal\ncargo install --path .\n```\n\nThis builds the Rust binary and installs it to `~/.cargo/bin`, which is already on your `PATH` via `rustup`.\n\nThe shell hook lives in `scripts/zsh/smart-terminal.zsh`.\n\n```\ncat <<'EOF' >> ~/.zshrc\nsource /path/to/smart-terminal/scripts/zsh/smart-terminal.zsh\nreload() { source ~/.zshrc; }\nEOF\nsource ~/.zshrc\n```\n\nReplace `/path/to/smart-terminal` with the actual location where you cloned the repo.\n\n```\nsmart-terminal next-cmd \"list files\"\n```\n\nYou 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.\n\nPull the latest changes, rebuild the binary, and reload the zsh integration:\n\n```\ncd /path/to/smart-terminal\ngit pull\ncargo install --path . --force\nreload\n```\n\n`--force` replaces the existing binary in `~/.cargo/bin`, and `reload` re-sources your zsh config so the latest hook is active.\n\nOther open terminal tabs keep the old shell integration until you run `reload` in them or open a fresh session.\n\n- **Folder-scoped investigation state** — maintain one investigation conversation history per project folder, so the`investigate` agent can preserve context between sessions without mixing unrelated projects.\n- **Conversation management commands** — add commands to inspect or erase the stored investigation history when users want to start fresh.\n- **Alternative shell integrations** — native support for Fish, Bash, and Nushell.\n- **Offline / Local LLM support** — first-class integration with Ollama and`llama.cpp` .\n\nContributions, bug reports, and feature suggestions are warmly welcomed! 🎉\n\nAs 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.\n\nCheck out [CONTRIBUTING.md](https://github.com/sdi2200246/smart-terminal/blob/main/CONTRIBUTING.md) to get started with:\n\n- Local setup & testing guidelines\n- High-impact areas needing help (shells, providers, tools, performance)\n- Code conventions and PR submission workflow\n- Co-maintainership and stewardship opportunities\n\nBuilt with 🦀 by **Jason Stefanou**\n\nInformatics Undergraduate at the National and Kapodistrian University of Athens.\n\n- **Email:**[jasonstephanou3@gmail.com](mailto:jasonstephanou3@gmail.com)\n\nQuestions, setup issues, bug reports, and improvement ideas are always welcome.\n\nIf something breaks, feels unclear, or you have suggestions for new features or workflow improvements, feel free to open an issue or reach out directly.", "url": "https://wpnews.pro/news/smart-terminal-zsh-ghost-text-command-suggestions-with-reversibility", "canonical_source": "https://github.com/sdi2200246/smart-terminal", "published_at": "2026-11-28 12:59:59+00:00", "updated_at": "2026-11-28 13:12:17.639587+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "developer-tools", "large-language-models"], "entities": ["smart-terminal", "next-cmd", "Rust", "Groq", "OpenRouter", "Google Gemini", "zsh"], "also_reported_by": [], "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.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/smart-terminal-zsh-ghost-text-command-suggestions-with-reversibility", "markdown": "https://wpnews.pro/news/smart-terminal-zsh-ghost-text-command-suggestions-with-reversibility.md", "text": "https://wpnews.pro/news/smart-terminal-zsh-ghost-text-command-suggestions-with-reversibility.txt", "jsonld": "https://wpnews.pro/news/smart-terminal-zsh-ghost-text-command-suggestions-with-reversibility.jsonld"}}