opencode
opencode copied to clipboard
feat(bash): load user shell RC files for alias support
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 forloadRcFiles,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 useShell.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() |