Bang (!) command doesn't load user shell functions/aliases from .zshenv
Description
The ! (bang) shortcut for running shell commands inside Claude Code does not load the user's shell environment properly. Specifically, shell functions and aliases defined in ~/.zshenv (which should be sourced by all zsh instances, interactive or not) are not available when using !command.
Steps to Reproduce
- Define shell functions or aliases in
~/.zshenv(or a file sourced by it):
``zsh``
# ~/.zsh/env.zsh (sourced by ~/.zshenv)
ll() { eza -la --icons --group-directories-first --git "$@"; }
- Verify it works in a normal terminal:
ll→ works - Verify it works via Claude's Bash tool (asking Claude to run
ll) → works - Use
!llin the Claude Code prompt → fails, command not found
Expected Behavior
The ! command should respect the user's ~/.zshenv (or equivalent shell profile), since .zshenv is specifically designed to be loaded by all zsh invocations (interactive and non-interactive).
Actual Behavior
The ! command runs in a minimal shell context that doesn't source ~/.zshenv, so user-defined functions, aliases, and environment variables are not available.
Environment
- Claude Code CLI (latest)
- Shell: zsh 5.9
- OS: Fedora 43 (Linux)
Additional Context
The Bash tool (used when asking Claude to run commands) does load the shell environment correctly — it picks up functions from .zshenv. Only the ! shortcut is affected. It would be great if both used the same shell initialization path for consistency.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗