opencode plugin

June 5, 2026 · View on GitHub

Zsh plugin for the opencode AI coding agent. Compatible with oh‑my‑zsh.

Prerequisites

  • opencode CLI — install with npm install -g opencode-ai, or follow the install guide. The plugin does nothing without the opencode command on your $PATH.
  • zsh 5.1+ — any modern zsh works. No oh‑my‑zsh dependency for the standalone path, but $ZSH_CACHE_DIR must be set if you want completions (oh‑my‑zsh sets this automatically; for standalone shells the plugin falls back to $HOME/.cache/zsh).

Enable

Oh‑my‑zsh

Add opencode to your plugins array in .zshrc:

plugins=(... opencode)

Standalone (source directly)

Clone the repo and source the plugin file from .zshrc:

source /path/to/opencode.plugin.zsh

Quick start

If you want to...Type this
Launch opencode in this projectoc
Pick up where you left offocc
Ask a quick question, no TUIocr "question"
Attach to a remote serveroca <url>
Check your usage and costsocst
Upgrade to the latest versionocup

Aliases

All aliases use the oc prefix. The scheme helps you guess them:

After ocWhat it meansExamples
1 letterFlag nameocm = --model, ocp = --prompt
2 lettersSubcommandocr = run, ocmo = models
3+ lettersSubcommand + flag or subcommandocmor = models --refresh
NaturalCommon verb from other toolsoclogin / oclogout

Prefix oc runs opencode (the TUI). Add c for --continue to resume where you left off: occ, ocrc.

AliasCommandDescription
ocopencodeLaunch TUI
occopencode --continueContinue last session
ocfcopencode --fork --continueFork last session
ocmopencode --modelLaunch with a specific model
ocpopencode --promptLaunch with an initial prompt
ocpuopencode --pureLaunch without plugins
ocropencode runRun non-interactive
ocrcopencode run --continueContinue in run mode
ocrsopencode run --shareRun and share the session
ocrjopencode run --format jsonRun with JSON output
ocrfopencode run --fileRun with files attached
ocraopencode run --attachRun attached to a server
ocrqopencode run --dangerously-skip-permissionsQuick run (skip permission asks)
ocsopencode serveStart headless server
ocwopencode webStart server with web UI
ocaopencode attachAttach TUI to running server
ocacpopencode acpStart ACP server
ocauopencode authManage credentials
ocloginopencode auth loginLog in to a provider
ocaulopencode auth listList authenticated providers
oclogoutopencode auth logoutLog out of a provider
ocmoopencode modelsList available models
ocmoropencode models --refreshRefresh models cache
ocmovopencode models --verboseList models with metadata
ocmcopencode mcpManage MCP servers
ocmcaopencode mcp addAdd an MCP server
ocmclopencode mcp listList MCP servers
ocmcauopencode mcp authAuthenticate with an MCP server
ocmcloopencode mcp logoutRemove MCP credentials
ocmcdopencode mcp debugDebug MCP connection issues
ocagopencode agentManage agents
ocaglopencode agent listList agents
ocagcopencode agent createCreate a new agent
ocseopencode sessionManage sessions
ocselopencode session listList sessions
ocsedopencode session deleteDelete a session
ocstopencode statsShow usage statistics
ocstmopencode stats --modelsShow per-model usage breakdown
ocexopencode exportExport session data as JSON
ocimopencode importImport session from JSON/URL
ocghopencode githubManage GitHub agent
ocghiopencode github installInstall GitHub agent
ocghropencode github runRun GitHub agent
ocpropencode prFetch PR and run opencode on it
ocplopencode pluginInstall a plugin
ocplugopencode plugShorthand for plugin
ocplgopencode plugin --globalInstall plugin globally
ocdbgopencode debugDebugging and troubleshooting
ocdbopencode dbDatabase utilities
ocdbpopencode db pathPrint database file path
ocdbmopencode db migrateMigrate JSON data to SQLite
ocupopencode upgradeUpgrade opencode
ocunopencode uninstallUninstall opencode
occomopencode completionPrint shell completion script

Examples

# Start or continue a session in the current project
oc

# Continue where you left off
occ

# Ask a one-shot question without entering the TUI
ocr "What does this function do?"

# List available models from all configured providers
ocmo

# Run with JSON output, useful for scripting
ocrj "Check for security issues" > audit.json

# Start a headless server that other terminals can attach to
ocs --port 4096

# Attach a TUI to that server from another terminal
oca http://localhost:4096

# Show token usage and cost
ocst

# Install a plugin
ocpl opencode-model-scout

Completion

On the first shell startup after enabling this plugin, opencode completion zsh runs in the background and caches the output to $ZSH_CACHE_DIR/completions/_opencode. After that, tab-completion works for all opencode commands and flags.

If completions are missing or outdated, regenerate them manually:

opencode completion zsh > "$ZSH_CACHE_DIR/completions/_opencode"