[PR #7176] feat(bash): load user shell RC files for alias support #12286

Open
opened 2026-02-16 18:17:12 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7176

State: open
Merged: No


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()
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7176 **State:** open **Merged:** No --- ## 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()` |
yindo added the pull-request label 2026-02-16 18:17:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12286