Skip to content

lucleray/opencode-shell-commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  1. Add a custom command that starts with !:
// opencode.json
{
  "command": {
    "code": { "template": "!code .", "description": "Opened VS Code" },
  },
}
  1. Type /code and 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

  1. On startup, the plugin scans your commands for ! prefixed templates
  2. When you run one of those commands, the command.execute.before hook intercepts it
  3. The shell command runs via sh -c in your workspace
  4. If the command produces output (e.g. git status), it's added to the session context
  5. If the command is silent (e.g. cursor .), a toast confirms success
  6. The LLM call is skipped in both cases

License

MIT

About

Run shell commands directly from OpenCode custom commands, skipping the LLM entirely.

Resources

License

Stars

Watchers

Forks

Contributors