Skip to content

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

Closed as not planned

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.

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Nov 24, 2025
  2. github-actions commented on Nov 24, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of or related to existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  3. nikitakot commented on Nov 24, 2025

    @nikitakot
    Author

    this is similar to #3228
    but my request addresses windows problems

  4. rekram1-node commented on Nov 24, 2025

    @rekram1-node
    Contributor

    Yeah im gonna make windows better, there are some easy wins to do here that i can prolly do today as far as making it configurable in your opencode.json that may be a separate followup item.

  5. self-assigned this
    on Nov 24, 2025
  6. nikitakot commented on Nov 24, 2025

    @nikitakot
    Author

    @rekram1-node btw can confirm CC doesn't have the orphaned bash.exe problem anymore, just tried, so it's def possible to fix properly

  7. jdanbrown commented on Dec 3, 2025

    @jdanbrown
    Contributor

    Another idea here: present multiple shell/bash tools to the model, and let it pick when to use which one.

    e.g. In my usage of opencode, I set the $SHELL env var to a custom script that runs in a docker container with a readonly view of my fs, so that I can set "bash": "allow" permissions and not have to approve all the random stuff the model wants to run. But, a big downside of this is the model can't run anything on my macos host machine (which I would gate with "bash": "ask"), like running xcodebuild to build my ios code, or fix weird environment issures, or whatever.

    So maybe it'd open up some interesting use cases to support multiple shell tools (with appropriate descriptions for each: #4866).

  8. joeskeen commented on Mar 5, 2026

    @joeskeen

    Another idea here: present multiple shell/bash tools to the model, and let it pick when to use which one.

    e.g. In my usage of opencode, I set the $SHELL env var to a custom script that runs in a docker container with a readonly view of my fs, so that I can set "bash": "allow" permissions and not have to approve all the random stuff the model wants to run. But, a big downside of this is the model can't run anything on my macos host machine (which I would gate with "bash": "ask"), like running xcodebuild to build my ios code, or fix weird environment issures, or whatever.

    So maybe it'd open up some interesting use cases to support multiple shell tools (with appropriate descriptions for each: #4866).

    @jdanbrown this is a cool idea, I think it'd be pretty easy to make your custom script be its own custom tool, and put instructions in the Agents.md file to use your custom tool for code-related commands, and bash for system-scope commands. That way you could put allow on your custom tool but ask on the bash tool.

    Edit: I'd personally like to see that custom script, sounds pretty cool.

  9. jdanbrown commented on Mar 5, 2026

    @jdanbrown
    Contributor

    @joeskeen Here it is! It's pretty specific to my own dev needs (python, swift, fly, etc), but it's pretty small and simple so if you wanted to fork it into something that works for you then it should be pretty easy:

  10. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on May 3, 2026
  11. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions