anomalyco / anomalyco/opencode
[FEATURE] /editor should be able to open the current working directory in $EDITOR
@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.
/openor/cwd) that runs$EDITOR $CWD - Extend
/editorwith 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$EDITORin the current working directory
Acceptance criteria
- User can open the current working directory in
$EDITORwith a single command or keybind - Works correctly with GUI editors that require
--wait(honors the full$EDITORvalue) - 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
$EDITORresolution logic that/editorand/exportalready use cmd.Start()(notRun) for GUI editors so the TUI doesn't block; but detect terminal editors (nvim, vim, nano) and useRun+ suspend TUI → resume pattern (same as/editordoes 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
/editordocs: https://opencode.ai/docs/tui/#editor/exportuses the same$EDITORmechanism- #43223 — proposes
/cddirectory-switching command andchange_directoryagent 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.