Skip to content

feat: Add OPENCODE_CONFIG_DIR environment variable for config directory override #627

@kdcokenny

Description

@kdcokenny

Problem

OMO currently hardcodes configuration paths to ~/.config/opencode/oh-my-opencode.json without any mechanism to override the config directory location.

This breaks compatibility with tools like OCX that use profile-based isolation. OCX's ghost mode stores configurations per-profile:

~/.config/opencode/profiles/
├── default/
│   ├── opencode.jsonc
│   └── .opencode/oh-my-opencode.json
├── work/
│   └── ...
└── personal/
    └── ...

When running ocx ghost opencode, users expect their profile-specific OMO configuration to be used—but OMO always reads from the global path.

Proposed Solution

Add OPENCODE_CONFIG_DIR environment variable support, following the existing CLAUDE_CONFIG_DIR pattern already in the codebase.

Resolution order: OPENCODE_CONFIG_DIR → project config → XDG/global config

This allows tools like OCX to set the env var when spawning OpenCode:

OPENCODE_CONFIG_DIR=~/.config/opencode/profiles/work opencode

Benefits

  • Profile isolation — Different OMO settings per profile (work, personal, oss)
  • OCX compatibility — Ghost mode works seamlessly with OMO
  • Industry standard — Matches Docker (DOCKER_CONFIG), Cargo (CARGO_HOME), Claude Code (CLAUDE_CONFIG_DIR)
  • Minimal change — Follows existing pattern in src/shared/claude-config-dir.ts

Scope

  • Add env var check to src/shared/opencode-config-dir.ts
  • Update src/shared/config-path.ts to use shared logic
  • Add unit tests
  • Document in README

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions