opencode-shell-commands
v0.1.2
Published
Run shell commands directly from OpenCode custom commands, skipping the LLM entirely.
Maintainers
Readme
opencode-shell-commands
An OpenCode plugin that lets you execute shell for custom commands, skipping the LLM entirely.
Install
Add the plugin to your opencode.json:
{
"plugin": ["opencode-shell-commands"],
}Usage
- Add a custom command that starts with
!:
// opencode.json
{
"command": {
"code": { "template": "!code .", "description": "Opened VS Code" },
},
}- Type
/codeand VS Code opens instantly. No LLM round-trip.
Examples
Open current workspace in Cursor
// opencode.json
{
"command": {
"cursor": { "template": "!cursor .", "description": "Opened Cursor" },
},
}Open current workspace in Zed
// opencode.json
{
"command": {
"zed": { "template": "!zed .", "description": "Opened Zed" },
},
}Run pnpm commands
// opencode.json
{
"command": {
"lint": { "template": "!pnpm lint", "description": "Linted code" },
"test": { "template": "!pnpm test", "description": "Tests passed" },
},
}Run npm commands
// opencode.json
{
"command": {
"lint": { "template": "!npm run lint", "description": "Linted code" },
"test": { "template": "!npm run test", "description": "Tests passed" },
},
}Run bun commands
// opencode.json
{
"command": {
"lint": { "template": "!bun run lint", "description": "Linted code" },
"test": { "template": "!bun run test", "description": "Tests passed" },
},
}Git shortcuts
// opencode.json
{
"command": {
"gcm": {
"template": "!git checkout main",
"description": "Checked out main",
},
"gs": { "template": "!git status", "description": "Git status" },
},
}How it works
- On startup, the plugin scans your commands for
!prefixed templates - When you run one of those commands, the
command.execute.beforehook intercepts it - The shell command runs via
sh -cin your workspace - If the command produces output (e.g.
git status), it's added to the session context - If the command is silent (e.g.
cursor .), a toast confirms success - The LLM call is skipped in both cases
License
MIT
