Clear Session Keybind
Configure a keyboard shortcut for OpenCode 2's /clear command.
0
140
近 7 天 140
33.2
生态多维模型
3 天前
2026-10-01
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-clear-session-keybind@0.1.0"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-clear-session-keybind@0.1.0"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-clear-session-keybindOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
A configurable keyboard shortcut for OpenCode V2's built-in /clear command. It closes the current session tab and returns to a fresh prompt, keeping your selected agent and model. The saved session is not deleted.
Installation
Requires the OpenCode V2 CLI. Add this to your cli.json to use leader+C. Disabling the default compaction shortcut frees that key:
{
"$schema": "https://opencode.ai/v2/cli.json",
"keybinds": {
"session.compact": "none"
},
"plugins": [
{
"options": {
"keybind": "<leader>c"
},
"package": "opencode-clear-session-keybind"
}
]
}
Configuration
options.keybind is required and has no default. Set it to a non-empty shortcut string supported by OpenCode, such as <leader>c or ctrl+l. If you choose a different shortcut, you can keep OpenCode's compaction binding.
Configure the shortcut through the plugin's options. OpenCode does not accept session.clear under keybinds.
License
同类生态推荐
Tui Quota Usage
opencode-tui-quota-usage
OpenCode quota usage sidebar tracker for OpenCode V2 CLI/TUI
Circadian
opencode-circadian
Automatically switch your opencode TUI theme by time of day — a day theme and a night theme, with a gentle manual override.
Go Usage
@pistonex/opencode-go-usage
OpenCode TUI plugin that shows OpenCode Go subscription usage (rolling / weekly / monthly) in the sidebar