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

Open
opened 2026-02-16 17:38:31 -05:00 by yindo · 5 comments
Owner

Originally created by @nikitakot on GitHub (Nov 24, 2025).

Originally assigned to: @rekram1-node on GitHub.

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.
Originally created by @nikitakot on GitHub (Nov 24, 2025). Originally assigned to: @rekram1-node on GitHub. ### Feature hasn't been suggested before. - [x] 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](https://code.claude.com/docs/en/setup#windows-setup) 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 ```jsonc { "$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 } } } ``` 2. allow switching shell at runtime with `/shell` command or something similar 3. 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.
yindo added the discussion label 2026-02-16 17:38:31 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 24, 2025):

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

  • #4671: Shell mode (!) is broken on Windows Powershell
  • #3228: Allow the user to run their favorite shell in opencode
  • #4599: Bash tool executes bash commands with cmd.exe
  • #4379: Specific bash commands fail on Windows in Git Bash due to path re-mapping
  • #4392: Blockers: Switching from Claude Code to OpenCode on Windows (includes shell configuration)

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

@github-actions[bot] commented on GitHub (Nov 24, 2025): This issue might be a duplicate of or related to existing issues. Please check: - #4671: Shell mode (`!`) is broken on Windows Powershell - #3228: Allow the user to run their favorite shell in opencode - #4599: Bash tool executes bash commands with cmd.exe - #4379: Specific bash commands fail on Windows in Git Bash due to path re-mapping - #4392: Blockers: Switching from Claude Code to OpenCode on Windows (includes shell configuration) Feel free to ignore if none of these address your specific case.
Author
Owner

@nikitakot commented on GitHub (Nov 24, 2025):

this is similar to https://github.com/sst/opencode/issues/3228
but my request addresses windows problems

@nikitakot commented on GitHub (Nov 24, 2025): this is similar to https://github.com/sst/opencode/issues/3228 but my request addresses windows problems
Author
Owner

@rekram1-node commented on GitHub (Nov 24, 2025):

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.

@rekram1-node commented on GitHub (Nov 24, 2025): 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.
Author
Owner

@nikitakot commented on GitHub (Nov 24, 2025):

@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

@nikitakot commented on GitHub (Nov 24, 2025): @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
Author
Owner

@jdanbrown commented on GitHub (Dec 3, 2025):

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: https://github.com/sst/opencode/issues/4866).

@jdanbrown commented on GitHub (Dec 3, 2025): 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: https://github.com/sst/opencode/issues/4866).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3081