GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(opencode): add configurable shell resolution with plugin support by JohnDeved · Pull Request #9724 · anomalyco/opencode

Conversation

@JohnDeved

@JohnDeved JohnDeved commented Jan 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Summary

Adds a first-class way to control which shell OpenCode uses when executing commands. Users (and plugin authors) can now override shell resolution explicitly instead of relying on $SHELL and platform defaults.

Fixes #4702

Problem

Today, the bash tool’s shell selection is implicit: OpenCode primarily relies on $SHELL and then falls back to OS defaults. That’s fine for simple local setups, but it breaks down whenever “my login shell” is not the same as “the shell OpenCode should execute commands with.” $SHELL is global, can point at non-POSIX shells, and is often misleading in containerized/remote/dev environments (#8396), forcing users into brittle workarounds (wrapper scripts, aliases, or forks) just to control command execution.

This shows up in several common scenarios:

  • Sandboxed execution / safer “allow” mode: Teams want to route commands through a controlled entrypoint (e.g., a wrapper that runs docker run with a read-only filesystem) so they can set "bash": "allow" without approving every command while still reducing risk. [FEATURE]: Add config to change shell for bash tool #4702
  • Non-POSIX login shells: Developers using Fish/Nushell as their default shell still need OpenCode to run Bash/Zsh for agent-generated scripts and tooling compatibility. Opencode Desktop error with nushell as default shell #8716
  • Per-project consistency: Repos may require a specific shell (e.g., /bin/bash for CI parity or /bin/zsh for team conventions) independent of the user’s interactive environment.
  • Remote & ephemeral environments: In nix-shell, devcontainers, SSH sessions, or remote IDEs, $SHELL can reflect the host/login context rather than the environment where commands should run leading to surprising behavior and “works on my machine” inconsistencies.
  • Enterprise policy & compliance: Orgs often need to standardize execution through an approved shell entrypoint (auditing, environment bootstrapping, restricted PATH), which must be configurable without asking every developer to change their global shell.

Solution

Shell resolution is now explicit and extensible, while preserving existing behavior by default. OpenCode resolves the shell using the following priority order:

  1. Config override set "shell": "/bin/zsh" (or a wrapper) in opencode.json
  2. Plugin hook shell.resolve can dynamically choose a shell per workspace/environment
  3. Environment $SHELL (existing behavior)
  4. Fallback system default (existing behavior)

This keeps backward compatibility for current users, but unlocks predictable, per-project and policy-driven shell behavior for advanced setups.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

stevoland and kuzkokov reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@JohnDeved
feat(opencode): add configurable shell resolution with plugin support
56cd985
- Add 'shell' config option to opencode.json for explicit shell override
- Add 'shell.resolve' plugin hook for dynamic shell resolution
- Convert Shell.preferred() and Shell.acceptable() to async
- Update call sites in bash tool, pty, and prompt to await shell
- Add comprehensive tests for config, plugin, and fallback scenarios
- Regenerate SDK types to include new shell config property
Copilot AI review requested due to automatic review settings January 20, 2026 23:38
@github-actions github-actions Bot added the needs:issue label Jan 20, 2026
@github-actions

github-actions Bot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot started reviewing on behalf of JohnDeved January 20, 2026 23:38
View session
@github-actions

github-actions Bot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI reviewed Jan 20, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds configurable shell resolution with plugin support to OpenCode, allowing users to override shell detection through configuration or plugins instead of relying solely on environment variables.

Changes:

  • Added shell configuration field to allow explicit shell path override
  • Implemented plugin hook shell.resolve for dynamic shell resolution
  • Converted Shell.preferred() and Shell.acceptable() from synchronous to async functions
  • Updated all call sites to use await with the newly async shell functions

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/opencode/src/config/config.ts Added optional shell field to config schema
packages/sdk/openapi.json Regenerated SDK with new shell config field
packages/sdk/js/src/v2/gen/types.gen.ts Regenerated TypeScript types with shell config
packages/plugin/src/index.ts Added shell.resolve hook for plugin-based shell resolution
packages/opencode/src/shell/shell.ts Converted to async, added config/plugin resolution with priority chain
packages/opencode/src/tool/bash.ts Added await to Shell.acceptable() call
packages/opencode/src/pty/index.ts Added await to Shell.preferred() call
packages/opencode/src/session/prompt.ts Added await to Shell.preferred() call
packages/opencode/test/shell/shell.test.ts Added 4 tests for config, plugin, and fallback behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/opencode/test/shell/shell.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/test/shell/shell.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/test/shell/shell.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/test/shell/shell.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/test/shell/shell.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@JohnDeved JohnDeved mentioned this pull request Jan 20, 2026
[FEATURE]: Add config to change shell for bash tool #4702
Closed
1 task done
@github-actions github-actions Bot removed the needs:issue label Jan 20, 2026
@JohnDeved
fix: address review comments on shell tests
d56d473
- Remove unused imports (Config, path)
- Add return statement to mock function
- Add test for Shell.acceptable() with plugin
- Add test for Shell.acceptable() fallback on blacklisted shell
@JohnDeved
JohnDeved requested a review from Copilot January 21, 2026 00:06
Copilot started reviewing on behalf of JohnDeved January 21, 2026 00:07
View session
Copilot AI reviewed Jan 21, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/opencode/src/config/config.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/plugin/src/index.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/test/shell/shell.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/shell/shell.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@JohnDeved
fix: address additional review comments
bfede1d
- Improve shell config description with priority info and examples
- Add JSDoc documentation for shell.resolve plugin hook
- Add test: config takes priority over plugin
- Add test: config can override blacklist for Shell.acceptable
@JohnDeved
JohnDeved requested a review from Copilot January 21, 2026 00:30
Copilot started reviewing on behalf of JohnDeved January 21, 2026 00:30
View session
Copilot AI reviewed Jan 21, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/sdk/openapi.json Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/sdk/js/src/v2/gen/types.gen.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/config/config.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/shell/shell.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@thdxr
thdxr force-pushed the dev branch from cbab81f to 2d3c7a0 Compare January 30, 2026 04:49
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 00637c0 to 71e0ba2 Compare January 30, 2026 14:32
@thdxr
thdxr force-pushed the dev branch 3 times, most recently from f1ae801 to 08fa7f7 Compare January 30, 2026 14:37
@github-actions github-actions Bot mentioned this pull request Feb 4, 2026
Inject OPENCODE_SESSION_ID into shell env #12159
Closed
@github-actions github-actions Bot mentioned this pull request Mar 1, 2026
fix(shell): blacklist POSIX-only shells for bash tool #15610
Closed
3 of 6 tasks
@github-actions

github-actions Bot commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Mar 22, 2026
@MotionDevLab MotionDevLab mentioned this pull request Oct 13, 2026
Windows: bash tool ignores shell: pwsh config — always runs PowerShell 5.1 (1.18.15) #41426
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add config to change shell for bash tool

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@JohnDeved
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.