opencode
opencode copied to clipboard
feat(bash): add config option to hide env prefix in command display
Summary
Add a config option to hide Claude's environment variable prefix in bash command display while keeping it intact for execution.
When using OpenCode with Claude (Anthropic) as the model provider, Claude adds a safety env prefix to bash commands:
export CI=true DEBIAN_FRONTEND=noninteractive GIT_TERMINAL_PROMPT=0 GCM_INTERACTIVE=never HOMEBREW_NO_AUTO_UPDATE=1 GIT_EDITOR=: EDITOR=: VISUAL='' GIT_SEQUENCE_EDITOR=: GIT_MERGE_AUTOEDIT=no GIT_PAGER=cat PAGER=cat npm_config_yes=true PIP_NO_INPUT=1 YARN_ENABLE_IMMUTABLE_INSTALLS=false; git status
This creates visual noise in the TUI. This PR adds a config option to hide this prefix in the display only - the command still executes with the env vars.
Changes
-
packages/util/src/bash.ts- NewstripEnvPrefix()utility function -
packages/opencode/src/config/config.ts- AddBashconfig schema withhideEnvPrefixoption -
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx- Apply filter in TUI Bash component -
packages/opencode/test/util/bash.test.ts- Unit tests for the utility function
Usage
Add to opencode.json:
{
"bash": {
"hideEnvPrefix": true
}
}
Before/After
Before (default, hideEnvPrefix: false):
$ export CI=true DEBIAN_FRONTEND=noninteractive ...; git status
After (hideEnvPrefix: true):
$ git status
Notes
- Default is
falsefor backwards compatibility - Web share view is unchanged (shows actual executed command, no config access)
- Display-only change - execution is unchanged
Closes #8668 Related to #2581