个性化
按你的偏好与工作流定制 OpenCode。下面的设置按其归属文件分组。
界面设置 → tui.json
终端界面有独立的配置文件。创建 ~/.config/opencode/tui.json(或 tui.jsonc)并写入需要的键。
主题
{
"$schema": "https://opencode.ai/tui.json",
"theme": "tokyonight"
}
Built-in themes include system, tokyonight, everforest, ayu, catppuccin, catppuccin-macchiato, gruvbox, kanagawa, nord, matrix, and one-dark. Custom themes are JSON files — see Themes.
快捷键
{
"$schema": "https://opencode.ai/tui.json",
"keybinds": {
"leader": "ctrl+x",
"command_list": "ctrl+p",
"theme_list": "<leader>t"
}
}
Disable a binding with "none". See Keybinds for the full list.
提示、游标与滚动
{
"$schema": "https://opencode.ai/tui.json",
"attention": {
"enabled": true,
"notifications": true,
"sound": true,
"volume": 0.4
},
"cursor": {
"style": "blink",
"blink": true
},
"scroll_speed": 3
}
智能体与运行时设置 → opencode.json
默认模型与默认智能体
{
"$schema": "https://opencode.ai/config.json",
"model": "anthropic/claude-sonnet-5-5",
"small_model": "anthropic/claude-haiku-5-5",
"default_agent": "build"
}
自定义智能体
{
"$schema": "https://opencode.ai/config.json",
"agent": {
"reviewer": {
"description": "Reviews code for correctness",
"model": "anthropic/claude-sonnet-5-5",
"prompt": "You are a code reviewer.",
"tools": { "write": false, "edit": false }
}
}
}
权限
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"edit": "ask",
"bash": "ask",
"webfetch": "allow"
}
}
格式化与 LSP 服务器
{
"$schema": "https://opencode.ai/config.json",
"formatter": true,
"lsp": true
}
指令、引用与监听
{
"$schema": "https://opencode.ai/config.json",
"instructions": ["CONTRIBUTING.md", ".cursor/zh-cn/rules/*.md"],
"watcher": {
"ignore": ["**/generated/**"]
}
}
ignore 属于 watcher 子项,不是顶层键。
下一步
| 你想修改 | 文件 | 页面 |
|---|---|---|
| 配色与自定义主题 | tui.json | Themes |
| 键盘快捷键 | tui.json | Keybinds |
| 模型、供应商、凭据 | opencode.json | Models, Providers |
| 智能体与提示词 | opencode.json | Agents |
| 工具权限 | opencode.json | Permissions |
| 保存时自动格式化 | opencode.json | Formatters |
| 语言服务器 | opencode.json | LSP |
| MCP 服务器 | opencode.json | MCP servers |
| 项目规则 | AGENTS.md | Rules |