Skip to content

gkzhb/ocm.fish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Opencode Configuration Manager (ocm)

ocm is a command-line tool for managing opencode configuration files, similar to how nvm manages Node.js versions.

This project is inspired by hungthai1401/occtx and vibe coded with sst/opencode & Kimi K2.

Features

  • List all available configurations
  • Switch between configurations
  • Create new configurations
  • Edit existing configurations
  • Delete configurations
  • Copy configurations
  • Backup and restore configurations

Installation

Install with Fisher:

fisher install gkzhb/ocm.fish

Usage

Basic Commands

# List all available configurations
ocm list

# Show current configuration
ocm current

# Switch to specified configuration
ocm use dev-plugin

# Set default configuration
ocm default myconfig

# Create new configuration
ocm create myconfig

# Edit configuration
ocm edit myconfig

# Delete configuration
ocm delete myconfig

# Copy configuration
ocm copy source-config dest-config

# Backup current configuration
ocm backup

# Restore from backup
ocm restore backup_20251120_005705

Environment Variables

  • OPENCODE_CONFIG: Specify the configuration file path to use (supports both .json and .jsonc formats)
  • ocm_current_config: Fish variable showing the current active configuration name (similar to nvm_current_version)
  • ocm_default_config: Universal Fish variable showing the default configuration name (similar to nvm_default_version)
# Use custom configuration file
OPENCODE_CONFIG=~/myconfig.jsonc opencode
OPENCODE_CONFIG=~/myconfig.json opencode

# Or set environment variable first
export OPENCODE_CONFIG=~/myconfig.jsonc
opencode

# Check current and default configurations
echo $ocm_current_config
echo $ocm_default_config

# Note: Default configuration is stored as a universal variable and persists across all Fish shell sessions

Configuration Structure

Configuration files are stored in the following locations:

  • Default configuration: ~/.config/opencode/opencode.jsonc or ~/.config/opencode/opencode.json
  • Other configurations: ~/.config/opencode/settings/<name>.jsonc or ~/.config/opencode/settings/<name>.json
  • Backup files: ~/.config/opencode/backups/backup_<timestamp>.jsonc or ~/.config/opencode/backups/backup_<timestamp>.json

Note: Both .json and .jsonc (JSON with comments) formats are supported.

Configuration Example

Basic configuration file structure:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": [],
  "provider": {},
  "permission": {
    "edit": "ask",
    "bash": "ask"
  },
  "instructions": [],
  "mcp": {},
  "share": "disabled",
  "autoupdate": false
}

Notes

  1. Confirmation prompt when deleting configurations
  2. Configuration switching is achieved by setting the OPENCODE_CONFIG environment variable (does not completely replace the default config file, but merges the contents of the OPENCODE_CONFIG config file on top of it and the project config)
  3. Backup files are automatically created in the ~/.config/opencode/backups/ directory
  4. Both .json and .jsonc (JSON with comments) formats are supported for all configuration files
  5. Default configuration is stored as a Fish universal variable (ocm_default_config) and persists across all Fish shell sessions and terminal restarts

Comparison with nvm

nvm ocm
nvm list ocm list
nvm use <version> ocm use <config>
nvm current ocm current
nvm install <version> ocm create <config>
nvm alias default <version> ocm default <config>
$nvm_current_version $ocm_current_config
$nvm_default_version $ocm_default_config
Manages Node.js versions Manages opencode configurations

About

OpenCode config manager

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages