| title | TUI |
|---|---|
| description | Using the OpenCode terminal user interface. |
import { Tabs, TabItem } from "@astrojs/starlight/components"
OpenCode provides an interactive terminal interface or TUI for working on your projects with an LLM.
Running OpenCode starts the TUI for the current directory.
opencodeOr you can start it for a specific working directory.
opencode /path/to/projectOnce you're in the TUI, you can prompt it with a message.
Give me a quick summary of the codebase.
You can reference files in your messages using @. This does a fuzzy file search in the current working directory.
:::tip
You can also use @ to reference files in your messages.
:::
How is auth handled in @packages/functions/src/api/index.ts?
The content of the file is added to the conversation automatically.
Start a message with ! to run a shell command.
!ls -laThe output of the command is added to the conversation as a tool result.
When using the OpenCode TUI, you can type / followed by a command name to quickly execute actions. For example:
/helpMost commands also have keybind using ctrl+x as the leader key, where ctrl+x is the default leader key. Learn more.
Here are all available slash commands:
Add a provider to OpenCode. Allows you to select from available providers and add their API keys.
/connectCompact the current session. Alias: /summarize
/compactKeybind: ctrl+x c
Toggle tool execution details.
/detailsKeybind: ctrl+x d
Open external editor for composing messages. Uses the editor set in your EDITOR environment variable. Learn more.
/editorKeybind: ctrl+x e
Exit OpenCode. Aliases: /quit, /q
/exitKeybind: ctrl+x q
Export current conversation to Markdown and open in your default editor. Uses the editor set in your EDITOR environment variable. Learn more.
/exportKeybind: ctrl+x x
Show the help dialog.
/helpKeybind: ctrl+x h
Create or update AGENTS.md file. Learn more.
/initKeybind: ctrl+x i
List available models.
/modelsKeybind: ctrl+x m
Start a new session. Alias: /clear
/newKeybind: ctrl+x n
Redo a previously undone message. Only available after using /undo.
:::tip Any file changes will also be restored. :::
Internally, this uses Git to manage the file changes. So your project needs to be a Git repository.
/redoKeybind: ctrl+x r
List and switch between sessions. Aliases: /resume, /continue
/sessionsKeybind: ctrl+x l
Share current session. Learn more.
/shareKeybind: ctrl+x s
List available themes.
/themeKeybind: ctrl+x t
Undo last message in the conversation. Removes the most recent user message, all subsequent responses, and any file changes.
:::tip Any file changes made will also be reverted. :::
Internally, this uses Git to manage the file changes. So your project needs to be a Git repository.
/undoKeybind: ctrl+x u
Unshare current session. Learn more.
/unshareBoth the /editor and /export commands use the editor specified in your EDITOR environment variable.
# For GUI editors, VS Code, Cursor, VSCodium, Windsurf, Zed, etc.
# include --wait
export EDITOR="code --wait"
```
To make it permanent, add this to your shell profile;
`~/.bashrc`, `~/.zshrc`, etc.
# For GUI editors, VS Code, Cursor, VSCodium, Windsurf, Zed, etc.
# include --wait
set EDITOR=code --wait
```
To make it permanent, use **System Properties** > **Environment
Variables**.
# For GUI editors, VS Code, Cursor, VSCodium, Windsurf, Zed, etc.
# include --wait
$env:EDITOR = "code --wait"
```
To make it permanent, add this to your PowerShell profile.
Popular editor options include:
code- Visual Studio Codecursor- Cursorwindsurf- Windsurfnvim- Neovim editorvim- Vim editornano- Nano editornotepad- Windows Notepadsubl- Sublime Text
:::note
Some editors like VS Code need to be started with the --wait flag.
:::
Some editors need command-line arguments to run in blocking mode. The --wait flag makes the editor process block until closed.
You can customize TUI behavior through your OpenCode config file.
{
"$schema": "https://opencode.ai/config.json",
"tui": {
"scroll_speed": 3,
"scroll_acceleration": {
"enabled": true
},
"sidebar": "hide"
}
}scroll_acceleration- 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 overscroll_speedand overrides it when enabled.scroll_speed- Controls how fast the TUI scrolls when using scroll commands (minimum:1). Defaults to1on Unix and3on Windows. Note: This is ignored ifscroll_acceleration.enabledis set totrue.sidebar- Sets the initial sidebar behavior (default:"auto"uses the responsive layout,"show"forces it visible,"hide"keeps it hidden until toggled)
You can customize various aspects of the TUI view using the command palette (ctrl+x h or /help). These settings persist across restarts.
Toggle whether your username appears in chat messages. Access this through:
- Command palette: Search for "username" or "hide username"
- The setting persists automatically and will be remembered across TUI sessions