個性化

OpenCode 各項個性化設定的位置——主題與快捷鍵在 tui.json,模型與 Agents 在 opencode.json,格式化、權限等設定索引。

本頁內文若連結到尚未提供繁體版本的頁面(例如 /ecosystem/plugins/、/news/),會開啟英文原頁;導覽與頁尾標有 EN 的項目即為這類頁面。

按你的偏好與工作流定製 OpenCode。下面的設定依其歸屬檔案分組。

介面設定 → tui.json

終端介面有獨立的設定檔。建立 ~/.config/opencode/tui.json(或 tui.jsonc)並寫入需要的鍵。

主題

{
  "$schema": "https://opencode.ai/tui.json",
  "theme": "tokyonight"
}

內建主題包含 system、tokyonight、everforest、ayu、catppuccin、catppuccin-macchiato、gruvbox、kanagawa、nord、matrix 與 one-dark。自訂主題是 JSON 檔案——請見主題。

快捷鍵

{
  "$schema": "https://opencode.ai/tui.json",
  "keybinds": {
    "leader": "ctrl+x",
    "command_list": "ctrl+p",
    "theme_list": "<leader>t"
  }
}

以 "none" 停用某個綁定。完整清單請見快捷鍵。

提示、游標與捲動

{
  "$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主題
鍵盤快捷鍵tui.json快捷鍵
模型、供應商、憑證opencode.json模型、供應商
智慧代理與提示詞opencode.json智慧代理
工具權限opencode.json權限
儲存時自動格式化opencode.json格式化工具
語言伺服器opencode.jsonLSP
MCP 伺服器opencode.jsonMCP 伺服器
專案規則AGENTS.md規則