[PR #5621] fix: enable shell alias expansion in ! command #11499

Closed
opened 2026-02-16 18:16:20 -05:00 by yindo · 0 comments
Owner

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

State: closed
Merged: Yes


Summary

Fixes shell aliases not working when using the ! command prefix (e.g., ! g status where g is aliased to git).

Closes #4351

Problem

Shell aliases weren't being expanded because:

  1. In non-interactive shells, alias expansion is disabled by default in both zsh and bash
  2. Even after enabling alias expansion with shopt -s expand_aliases (bash), the command was already parsed before the aliases were loaded

Solution

  • Add shopt -s expand_aliases for bash to enable alias expansion (works in ZSH without it)
  • Wrap the command in eval to defer parsing until after aliases are loaded
  • Use JSON.stringify to properly escape the command string
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5621 **State:** closed **Merged:** Yes --- ## Summary Fixes shell aliases not working when using the `!` command prefix (e.g., `! g status` where `g` is aliased to `git`). Closes #4351 ## Problem Shell aliases weren't being expanded because: 1. In non-interactive shells, alias expansion is disabled by default in both zsh and bash 2. Even after enabling alias expansion with `shopt -s expand_aliases` (bash), the command was already parsed before the aliases were loaded ## Solution - Add `shopt -s expand_aliases` for bash to enable alias expansion (works in ZSH without it) - Wrap the command in `eval` to defer parsing until after aliases are loaded - Use `JSON.stringify` to properly escape the command string
yindo added the pull-request label 2026-02-16 18:16:20 -05:00
yindo closed this issue 2026-02-16 18:16:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11499