fix: enable shell alias expansion in ! command
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:
- In non-interactive shells, alias expansion is disabled by default in both zsh and bash
- 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_aliasesfor bash to enable alias expansion (works in ZSH without it) - Wrap the command in
evalto defer parsing until after aliases are loaded - Use
JSON.stringifyto properly escape the command string
@Zeko369 In theory, this would be fantastic! My bash/fish aliases are burned into my muscle memory by now, I have to constantly remind myself that they don't work in opencode's Shell mode and shake my fist ruefully at the wasted extra keystrokes (who wants to tire their fingers out typing git status when my aliases should just let me just type gs?).
Looking at the diff, though, it doesn't look like this is going to work properly for fish/zsh/nu users (or probably for Windows who use Powershell either, I guess? Can't test, no Windows here). Is there anything we can do about that?
Thank you @Zeko369