Skip to content

[FEATURE]: allow multiple shell setups and allow switching them at runtime via TUI command #4683

@nikitakot

Description

@nikitakot

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

I'm using PowerShell on Windows and recently switched from Claude Code. While there are couple smaller bugs opencode works mostly fine and is definitely usable on Windows now.
However shell setup feels a bit messy. There is $SHELL env variable which seems to be respected by both Shell mode (!) and bash tool, but opencode defaults on Windows do not work well - cmd.exe is picked up for the bash tool and Shell mode doesn't seem to work.

Claude code solved it by using git bash path and it works great in most of the cases. The only problem with their approach I had is that long running processes via bash.exe (for ex. local http server npx serve) get orphaned, the cli can not terminate them, even when the cli gets closed. I confirm opencode behaves the same if I do $env:SHELL="C:\Program Files\Git\bin\bash.exe"; opencode.

I propose something like this:

  1. config
{
  "$schema": "https://opencode.ai/config.json",
  "shell": {
    // set the default
    "default": "cmd",
    "cmd": {
      "path": "{env:ComSpec}",
      // optionally let llm know what shell is used (or make it possible via plugin hooks)
      "prompt": "you are running in cmd.exe Windows environment. you must follow the Windows cmd syntax"
    },
    "bash": {
      "path": "C:\\Program Files\\Git\\bin\\bash.exe"
    },
    "pwsh": {
      "path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
      // optional
      "args": "-NoLogo -NoProfile",
      // optional
      "enabled": false
    }
  }
}
  1. allow switching shell at runtime with /shell command or something similar
  2. win32: use cmd (env:ComSpec) as the default but recommend to setup git bash (C:\Program Files\Git\bin\bash.exe) in docs as CC does

Concerns:

  • Most of LLMs try to use shell syntax, is it possible to add the shell information to system prompt based on the shell? However workaround for this can be also configured in instructions separately by user.
  • Different shells might behave differently when it comes to stdout/exit codes. I would cover bash, cmd and pwsh with tests and let end users know the rest is not officially supported (for win32).
  • The orphaned bash.exe is really annoying, I'm not sure what's the problem here for both CC and opencode.

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions