OpenCode: OpenCode TUI (Terminal User Interface)
Last updated: 2026-08-31
--- title: OpenCode TUI Terminal Interface description: Deep dive into the Terminal User Interface with slash commands, file references, and shortcuts order: 7 lang: en
TUI is OpenCode's core usage mode—code analysis, modification, and execution all happen through this interface.
1. What You Will Learn
- TUI startup and basic interaction
- File reference (@) feature
- Shell command execution (!)
- Complete slash command list
- Keyboard shortcuts
2. Start TUI
# Current directory
opencode
# Specify project directory
opencode /path/to/project
3. Basic Interaction
Type natural language in the input box:
Summarize this project's structure
OpenCode analyzes the project code and provides results.
4. File Reference (Core Feature)
Use @ to reference project files:
How is authentication implemented? Check @packages/functions/src/api/index.ts
Features:
- Fuzzy search for file paths
- Auto-reads file content
- No manual code copying
Ideal for reading unfamiliar code.
5. Execute Bash Commands
Use ! to switch to Shell mode:
!ls -la
Results are automatically added to conversation context for AI follow-up.
6. Slash Commands (/ Commands)
Type / to execute built-in commands:
| Command | Action | Shortcut |
|---|---|---|
/connect |
Add LLM provider | — |
/compact |
Compress session context | Ctrl+X → C |
/details |
Toggle tool execution details | Ctrl+X → D |
/editor |
Open external editor | Ctrl+X → E |
/exit |
Exit TUI | Ctrl+X → Q |
/export |
Export conversation as Markdown | Ctrl+X → X |
/help |
Open help panel | Ctrl+X → H |
/init |
Create/update AGENTS.md | Ctrl+X → I |
/models |
List available models | Ctrl+X → M |
/new |
New session | Ctrl+X → N |
/redo |
Redo undone operation | Ctrl+X → R |
/sessions |
Session list and switching | Ctrl+X → L |
/share |
Share current session | Ctrl+X → S |
/themes |
List/switch themes | Ctrl+X → T |
/thinking |
Show/hide reasoning process | — |
/undo |
Undo last message | Ctrl+X → U |
7. Keyboard Shortcuts
Ctrl + X is the default leader key (like Vim's Leader):
| Function | Shortcut |
|---|---|
| Command palette | Ctrl+X → H |
| New session | Ctrl+X → N |
| Undo | Ctrl+X → U |
| Redo | Ctrl+X → R |
| Model list | Ctrl+X → M |
| Theme switch | Ctrl+X → T |
| Export | Ctrl+X → X |
8. Editor Integration
export EDITOR="code --wait"
Then use /editor in TUI to open an external editor for complex prompts.
Supports: VS Code, Cursor, Vim/Neovim, Nano.
9. Session Management
| Operation | Command |
|---|---|
| New session | /new |
| View sessions | /sessions |
| Continue last | opencode --continue |
| Specify session | opencode --session <id> |
10. TUI Configuration
{
"tui": {
"scroll_speed": 3,
"scroll_acceleration": {
"enabled": true
}
}
}
11. TUI Essence
OpenCode TUI is a composite interaction layer of LLM + project context + Git state management + command palette:
| Prefix | Function | Analogy |
|---|---|---|
/ |
Control behavior | IDE command palette |
@ |
Inject context | File-level RAG |
! |
Execute environment ops | Shell tool call |
Ctrl+X |
Efficient shortcuts | Vim Leader key |
❓ FAQ
📖 Summary
- TUI is OpenCode's core interaction interface
@references files,!executes commands,/calls built-in commands- Ctrl+X is the shortcut leader key
- Use @ file references to improve accuracy
- Ensure Git commits before important operations
📝 Exercises
-
Basic: Use @ to reference a file in TUI and have AI analyze its code logic.
-
Intermediate: Use ! to execute a Shell command, then have AI provide suggestions based on results.
-
Advanced: Use /editor to write a complex multi-line prompt for a multi-step task.