Getting Started
Start the TUI by running:Start with a specific model
Use the-m or --model flag to start with a specific model:
Continue a previous session
Resume your last session with the-c or --continue flag:
Fork a session
Create a fork of an existing session to explore alternative approaches:Start with a prompt
Provide an initial prompt directly from the command line:File References
You can reference files in your messages using the@ symbol. This performs a fuzzy file search in your working directory:
Bash Commands
Start a message with! to run a shell command:
Slash Commands
The TUI supports slash commands for quick actions. Type/ followed by a command name:
ctrl+x as the leader key.
Available Commands
/connect
Add a provider to OpenCode. Select from available providers and add their API keys.
/compact
Compact (summarize) the current session to reduce context usage.
ctrl+x c
Alias: /summarize
/details
Toggle tool execution details visibility in the conversation.
ctrl+x d
/editor
Open an external editor for composing multi-line messages. Uses the editor specified in your EDITOR environment variable.
ctrl+x e
See Editor Setup for configuration instructions.
/exit
Exit OpenCode.
ctrl+x q
Aliases: /quit, /q
/export
Export the current conversation to Markdown and open it in your default editor.
ctrl+x x
/help
Show the help dialog with available commands and keybinds.
ctrl+x h
/init
Create or update the AGENTS.md file for project-specific rules and instructions.
ctrl+x i
/models
List available models from configured providers.
ctrl+x m
/new
Start a new session.
ctrl+x n
Alias: /clear
/redo
Redo a previously undone message. Only available after using /undo.
ctrl+x r
File changes made by the redone message will be restored. Your project must be a Git repository for this to work.
/sessions
List and switch between sessions.
ctrl+x l
Aliases: /resume, /continue
/share
Share the current session. Generates a shareable link to your conversation.
ctrl+x s
/theme
List and switch between available themes.
ctrl+x t
/thinking
Toggle visibility of thinking/reasoning blocks in the conversation. When enabled, you can see the model’s reasoning process for models that support extended thinking.
This command only controls whether thinking blocks are displayed - it doesn’t enable or disable the model’s reasoning capabilities. Use
ctrl+t to cycle through model variants that support reasoning./undo
Undo the last message in the conversation. Removes the most recent user message, all subsequent responses, and reverts any file changes.
ctrl+x u
File changes will be reverted using Git. Your project must be a Git repository for this to work.
/unshare
Unshare the current session, removing public access.
Keyboard Shortcuts
The TUI is designed for keyboard-driven workflows. Here are the essential shortcuts:Leader Key Commands
Most commands usectrl+x as the leader key, followed by a second key:
ctrl+x h- Show helpctrl+x n- New sessionctrl+x l- List sessionsctrl+x c- Compact sessionctrl+x d- Toggle detailsctrl+x e- Open editorctrl+x x- Export conversationctrl+x s- Share sessionctrl+x t- Change themectrl+x m- List modelsctrl+x i- Initialize AGENTS.mdctrl+x u- Undoctrl+x r- Redoctrl+x q- Quit
Navigation
PageUp/PageDown- Scroll by pageHome/End- Jump to start/end of conversation↑/↓- Navigate through message history
Model Variants
ctrl+t- Cycle through model variants (default, extended thinking, etc.)
Input Shortcuts
Enter- Submit messageMeta+Enter(macOS) orAlt+Enter(Linux/Windows) - Insert newlineEscape- Blur input field
Editor Setup
Both the/editor and /export commands use the editor specified in your EDITOR environment variable. If not set, they fall back to VISUAL.
Linux/macOS
Add to your shell profile (~/.bashrc, ~/.zshrc, etc.):
Windows (CMD)
Windows (PowerShell)
GUI editors like VS Code, Cursor, Windsurf, and Zed need the
--wait flag to block until the editor is closed.Configuration
You can customize TUI behavior through your OpenCode config file (opencode.json):
Options
scroll_speed
Controls how fast the TUI scrolls when using scroll commands (minimum: 1). Defaults to 3.
This setting is ignored if
scroll_acceleration.enabled is true.scroll_acceleration.enabled
Enable macOS-style scroll acceleration for smooth, natural scrolling. When enabled, scroll speed increases with rapid scrolling gestures and stays precise for slower movements.
This setting takes precedence over scroll_speed.
Customization
You can customize various aspects of the TUI through the command palette (ctrl+x h or /help). Settings persist across restarts.
Username Display
Toggle whether your username appears in chat messages:- Open command palette:
ctrl+x hor/help - Search for “username” or “hide username”
- Toggle the setting
Running with a Server
By default, the TUI communicates directly with OpenCode’s internal engine. You can optionally run a web server alongside the TUI:- Access the web interface at
http://localhost:4096 - Attach additional TUI instances to the same server
- Share sessions across multiple interfaces
Network Access
Make the server accessible on your local network:mDNS Discovery
Enable mDNS for automatic server discovery:opencode.local on your network.
Tips and Tricks
Auto-focus Input
The TUI automatically focuses the input field when you start typing (except when the terminal panel is open on desktop). This allows for a fluid, conversation-like experience.Scroll Behavior
The TUI automatically scrolls to follow new messages. If you scroll up to review previous messages, auto-scroll pauses. Scroll back to the bottom to resume auto-scrolling.Custom Commands
You can add custom slash commands through your OpenCode configuration. These commands can execute scripts, run build tools, or perform any custom automation.Agent Selection
Use the--agent flag to start with a specific agent: