anomalyco / anomalyco/opencode

[FEATURE] /editor should be able to open the current working directory in $EDITOR

Open
#44,474 1 comment 0 reactions 1 assignee View on GitHub

@simonklee is already working on this.

Since Aug 23, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Background

When working inside a git worktree (or any deeply nested project directory), the path is long and cumbersome to type. Users frequently want to open the current working directory — the one opencode was started in — in their $EDITOR (e.g. nvim, code --wait).

Currently the only way is to run a bash command manually:

!$EDITOR /path/to/my-project-worktrees/feature-some-long-branch-name

This requires copying or remembering the full path every time.

Problem

The /editor command opens an external editor for composing messages to the LLM, not for opening the project directory itself. There is no built-in command to launch $EDITOR against the current working directory.

Proposal

Add a way to open the current working directory in $EDITOR from within the TUI. Possible approaches:

  • A new slash command (e.g. /open or /cwd) that runs $EDITOR $CWD
  • Extend /editor with an optional argument (e.g. /editor . or /editor --dir) to open the directory instead of the message composer
  • A keybind shortcut (e.g. ctrl+x o) that opens $EDITOR in the current working directory
Acceptance criteria
  • User can open the current working directory in $EDITOR with a single command or keybind
  • Works correctly with GUI editors that require --wait (honors the full $EDITOR value)
  • Works with git worktrees (opens the worktree path, not the main repo)

Implementation ideas

Approach A: New /open command

Register a new slash command in the TUI command registry alongside /editor and /export:

// packages/tui/cmd/open.go
type OpenCommand struct{}

func (c *OpenCommand) Run(ctx context.Context, t *TUI) error {
    cwd := t.app.Cwd() // or config.Project.Worktree()
    editor := os.Getenv("EDITOR")
    if editor == "" {
        return fmt.Errorf("EDITOR is not set")
    }
    // Split editor in case it includes flags like "code --wait"
    parts := strings.Fields(editor)
    cmd := exec.Command(parts[0], append(parts[1:], cwd)...)
    return cmd.Start()
}

Register it in the command list:

// packages/tui/cmd/commands.go
{
    Name:    "open",
    Aliases: []string{"cwd"},
    Run:     &OpenCommand{},
    Keybind: "ctrl+x o",
},

Key points:

  • Reuse the same $EDITOR resolution logic that /editor and /export already use
  • cmd.Start() (not Run) for GUI editors so the TUI doesn't block; but detect terminal editors (nvim, vim, nano) and use Run + suspend TUI → resume pattern (same as /editor does for composing)
  • Use the project's working directory (worktree path if applicable), not os.Getwd(), to ensure correctness when opencode is running inside a worktree
Approach B: Extend /editor with an argument

Add an optional argument to the existing /editor command:

func (c *EditorCommand) Run(ctx context.Context, t *TUI, args []string) error {
    if len(args) > 0 && (args[0] == "." || args[0] == "--dir") {
        return openInEditor(t.app.Cwd())
    }
    // existing message-composer logic...
}

This avoids adding a new command but changes /editor semantics, which may be confusing.

Recommended: Approach A

A separate /open command is clearer — /editor keeps its "compose message" meaning, and /open is self-explanatory. Adding a ctrl+x o keybind makes it one keystroke.

Related

  • /editor docs: https://opencode.ai/docs/tui/#editor
  • /export uses the same $EDITOR mechanism
  • #43223 — proposes /cd directory-switching command and change_directory agent tool. That issue targets switching the session working directory between worktrees; this issue targets opening the current working directory in $EDITOR. They are complementary, not duplicates.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.