-
Notifications
You must be signed in to change notification settings - Fork 6.7k
feat(bash): load user shell RC files for alias support #7176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aryasaatvik
wants to merge
1
commit into
anomalyco:dev
Choose a base branch
from
aryasaatvik:feat/bash-tool-user-env
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+174
−181
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
- Extract shell execution logic from prompt.ts to shell.ts - Add Shell.execute method to centralize shell command execution - Simplify bash.ts by using Shell.execute - Ensure proper user environment variable handling across shells
606c4a5 to
db95476
Compare
aryasaatvik
added a commit
to aryasaatvik/opencode
that referenced
this pull request
Jan 12, 2026
## Summary
- Adds `Shell.execute()` unified function for shell command execution with RC file loading support
- Bash tool now loads user shell RC files (`.bashrc`, `.zshrc`, etc.) enabling access to aliases
- Refactors shell escape (`!` prefix) to use the same shared execution logic
## Changes
**`src/shell/shell.ts`**
- Added `Shell.execute()` function with options for `loadRcFiles`, `timeout`, `abort`, `onOutput`
- Added `getInvocationArgs()` helper for shell-specific invocation patterns (zsh, bash, fish, nu, cmd, powershell)
**`src/tool/bash.ts`**
- Replaced inline spawn logic with `Shell.execute({ loadRcFiles: true })`
- Bash tool now has access to user aliases and shell functions
- Added `TERM: "dumb"` for cleaner output
**`src/session/prompt.ts`**
- Refactored `shell()` function to use `Shell.execute()`
- Removed duplicated spawn logic
## Behavior Changes
| Feature | Before | After |
|---------|--------|-------|
| Bash tool RC files | Not loaded | Loaded (aliases work) |
| Bash tool TERM | Inherited | `"dumb"` |
| Code duplication | Separate implementations | Shared `Shell.execute()` |
Patchwork-Source: feat/bash-tool-user-env
Patchwork-PR: anomalyco#7176
Patchwork-Squashed: 2026-01-12T21:05:18.691Z
aryasaatvik
added a commit
to aryasaatvik/opencode
that referenced
this pull request
Jan 12, 2026
## Summary
- Adds `Shell.execute()` unified function for shell command execution with RC file loading support
- Bash tool now loads user shell RC files (`.bashrc`, `.zshrc`, etc.) enabling access to aliases
- Refactors shell escape (`!` prefix) to use the same shared execution logic
## Changes
**`src/shell/shell.ts`**
- Added `Shell.execute()` function with options for `loadRcFiles`, `timeout`, `abort`, `onOutput`
- Added `getInvocationArgs()` helper for shell-specific invocation patterns (zsh, bash, fish, nu, cmd, powershell)
**`src/tool/bash.ts`**
- Replaced inline spawn logic with `Shell.execute({ loadRcFiles: true })`
- Bash tool now has access to user aliases and shell functions
- Added `TERM: "dumb"` for cleaner output
**`src/session/prompt.ts`**
- Refactored `shell()` function to use `Shell.execute()`
- Removed duplicated spawn logic
## Behavior Changes
| Feature | Before | After |
|---------|--------|-------|
| Bash tool RC files | Not loaded | Loaded (aliases work) |
| Bash tool TERM | Inherited | `"dumb"` |
| Code duplication | Separate implementations | Shared `Shell.execute()` |
Patchwork-Source: feat/bash-tool-user-env
Patchwork-PR: anomalyco#7176
Patchwork-Squashed: 2026-01-12T21:05:18.691Z
aryasaatvik
added a commit
to aryasaatvik/opencode
that referenced
this pull request
Jan 12, 2026
## Summary
- Adds `Shell.execute()` unified function for shell command execution with RC file loading support
- Bash tool now loads user shell RC files (`.bashrc`, `.zshrc`, etc.) enabling access to aliases
- Refactors shell escape (`!` prefix) to use the same shared execution logic
## Changes
**`src/shell/shell.ts`**
- Added `Shell.execute()` function with options for `loadRcFiles`, `timeout`, `abort`, `onOutput`
- Added `getInvocationArgs()` helper for shell-specific invocation patterns (zsh, bash, fish, nu, cmd, powershell)
**`src/tool/bash.ts`**
- Replaced inline spawn logic with `Shell.execute({ loadRcFiles: true })`
- Bash tool now has access to user aliases and shell functions
- Added `TERM: "dumb"` for cleaner output
**`src/session/prompt.ts`**
- Refactored `shell()` function to use `Shell.execute()`
- Removed duplicated spawn logic
## Behavior Changes
| Feature | Before | After |
|---------|--------|-------|
| Bash tool RC files | Not loaded | Loaded (aliases work) |
| Bash tool TERM | Inherited | `"dumb"` |
| Code duplication | Separate implementations | Shared `Shell.execute()` |
Patchwork-Source: feat/bash-tool-user-env
Patchwork-PR: anomalyco#7176
Patchwork-Squashed: 2026-01-12T21:05:18.691Z
aryasaatvik
added a commit
to aryasaatvik/opencode
that referenced
this pull request
Jan 13, 2026
## Summary
- Adds `Shell.execute()` unified function for shell command execution with RC file loading support
- Bash tool now loads user shell RC files (`.bashrc`, `.zshrc`, etc.) enabling access to aliases
- Refactors shell escape (`!` prefix) to use the same shared execution logic
## Changes
**`src/shell/shell.ts`**
- Added `Shell.execute()` function with options for `loadRcFiles`, `timeout`, `abort`, `onOutput`
- Added `getInvocationArgs()` helper for shell-specific invocation patterns (zsh, bash, fish, nu, cmd, powershell)
**`src/tool/bash.ts`**
- Replaced inline spawn logic with `Shell.execute({ loadRcFiles: true })`
- Bash tool now has access to user aliases and shell functions
- Added `TERM: "dumb"` for cleaner output
**`src/session/prompt.ts`**
- Refactored `shell()` function to use `Shell.execute()`
- Removed duplicated spawn logic
## Behavior Changes
| Feature | Before | After |
|---------|--------|-------|
| Bash tool RC files | Not loaded | Loaded (aliases work) |
| Bash tool TERM | Inherited | `"dumb"` |
| Code duplication | Separate implementations | Shared `Shell.execute()` |
Patchwork-Source: feat/bash-tool-user-env
Patchwork-PR: anomalyco#7176
Patchwork-Squashed: 2026-01-12T21:05:18.691Z
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Shell.execute()unified function for shell command execution with RC file loading support.bashrc,.zshrc, etc.) enabling access to aliases!prefix) to use the same shared execution logicChanges
src/shell/shell.tsShell.execute()function with options forloadRcFiles,timeout,abort,onOutputgetInvocationArgs()helper for shell-specific invocation patterns (zsh, bash, fish, nu, cmd, powershell)src/tool/bash.tsShell.execute({ loadRcFiles: true })TERM: "dumb"for cleaner outputsrc/session/prompt.tsshell()function to useShell.execute()Behavior Changes
"dumb"Shell.execute()