Rich prompt editor
Ghostex intercepts agent CLI prompt editing so Ctrl+G opens a rich editor instead of a bare shell buffer. Choose a floating Monaco overlay, the terminal-native gte editor, your system editor, or a custom command.
What it is
Agent CLIs such as Claude Code and Codex expose prompt editing through the shell editor contract: when you press Ctrl+G (or otherwise invoke $EDITOR), the CLI writes draft text to a temp file and waits for your editor to finish.
Ghostex replaces the default editor for sessions it launches. New terminals receive EDITOR and VISUAL pointing at ghostex prompt-editor, which routes to the backend you selected in Settings. The result is multi-line editing, image attachments, and a writing surface that stays inside your Ghostex workspace.
How it works
When a terminal session starts, Ghostex injects environment variables that describe the chosen backend:
EDITOR=ghostex prompt-editor
VISUAL=ghostex prompt-editor
GHOSTEX_PROMPT_EDITOR_BACKEND=monaco # or gte, custom, inherit
GHOSTEX_PROMPT_EDITOR_CLIENT=macos-appFor the Monaco floating editor backend, Ghostex opens a resizable WebKit overlay near the launching terminal pane. Save writes trimmed text back to the waiting CLI process and returns focus to the correct terminal. Cancel discards edits using the same status-file contract.
For gte (Ghostex Terminal Editor), editing stays inside the launching terminal. Ghostex exports a plain gte command and installs a zsh startup shim so user shell profiles cannot override the editor after load.
For zmx persistent sessions, prompt-editor routing follows the currently attached client. The macOS app can pass --prompt-editor monaco to zmx attach when Monaco is selected locally, while SSH, mobile, and TUI attaches use terminal-native gte because they cannot reach the local floating overlay.
Editor backends
| Option | What it does |
|---|---|
Monaco floating editor (default) | Opens a floating Monaco pane with save/cancel chrome. Best for long prompts and image paste. Default for new installs. |
gte terminal editor | Runs inside the terminal that invoked Ctrl+G. Install from Homebrew with the Settings Install gte button (brew install maddada/tap/gte). |
Inherit from system | Leaves EDITOR/VISUAL alone so your shell’s normal editor handles Ctrl+G. |
Custom | Runs your own command for both EDITOR and VISUAL. Default placeholder is code --wait. |
Options and settings
Settings → Terminal:
| Option | What it does |
|---|---|
promptEditorBackend | Label: "Ctrl+G prompt editor". Options: Inherit from system, Monaco floating editor, gte terminal editor, Custom. |
customPromptEditorCommand | Shown when backend is Custom. Label: "Custom Ctrl+G editor command". Written exactly into EDITOR/VISUAL. |
Install gte | Button beside the backend selector. Runs brew install maddada/tap/gte through the user’s Homebrew. |
terminalPastePreviewableImages | Terminal Behavior toggle (default on). Paste clipboard images as previewable Markdown links with Cmd+V or Ctrl+V. Same preview behavior appears in the Monaco prompt editor. |
debuggingMode | When enabled, gte prompt-editor diagnostics append to ~/Library/Logs/ghostex/gte-prompt-editor.log. |
SSH-connected shells without an explicit Ghostex prompt-editor backend strip stale Ghostex EDITOR overlays so remote sessions keep their normal editor values.
Monaco editor behavior
- The overlay prewarms after startup so the first real Ctrl+G edit opens faster.
- Clicking blank editor chrome keeps keyboard focus inside the editor instead of falling through to the terminal.
- Trailing blank lines are trimmed on save so agent prompts do not carry extra newlines.
- Image paste stores durable local references under ~/.ghostex/i with thumbnail previews, full-size popups, and one-click removal.
- Command-click (or equivalent) on [Image #N](path) links in terminal buffers can open the image file.
- While the Monaco editor is open, sidebar navigation may change selection behind it, but focus returns through the save/cancel path — not by stealing focus mid-edit.
Keyboard shortcuts
| Option | What it does |
|---|---|
Ctrl+G (in agent CLI) | Standard agent shortcut to open the configured prompt editor. Inside the Monaco overlay, Ctrl+G saves. |
Cmd+S | Saves the Monaco floating prompt editor (same as Ctrl+G inside the overlay). |
Escape | First press arms Cancel confirmation; second press within three seconds discards. Closes an open image preview without counting toward cancel. |
Cmd+V / Ctrl+V | Paste images into the Monaco editor when Paste previewable images is enabled. |
Remote and attach behavior
Monaco is the default for local macOS app terminals, but remote contexts cannot use the floating overlay:
- SSH sessions with Monaco selected in Settings resolve to gte at runtime.
- Explicit gte selections stay gte in every terminal context, including SSH.
- zmx attach from the macOS app passes --prompt-editor monaco only when the local client capability is Monaco.
- Remote attach copies the stable ghostex attach contract; prompt-editor capability is a current-client setting, not stored on the session forever.
CLI commands
End users normally trigger prompt editing through Ctrl+G inside an agent CLI. Ghostex wires the CLI bridge internally:
ghostex prompt-editor <file> # invoked as EDITOR by agent sessionsThere is no separate public gx subcommand for opening the prompt editor manually. Install gte through Settings or Homebrew when you want the terminal-native backend available outside Ghostex-managed sessions.
Tips
- Use Monaco for long prompts, pasted logs, and screenshots; switch to gte when you prefer staying inside the terminal grid.
- If Ctrl+G focus feels wrong after closing the editor, click the session in the sidebar — Ghostex reuses the same focus path as a normal session selection.
- Hold Cmd over a pasted image link in the terminal to preview it before sending the prompt.
- Choose Inherit from system when you want Ghostex terminals to behave like a normal shell for editor routing.
- Custom backend is useful for code --wait, vim -f, or any editor that blocks until the file is closed.