Bang (!) command doesn't load user shell functions/aliases from .zshenv

Resolved 💬 3 comments Opened Feb 14, 2026 by tulioteixeira2020-debug Closed Mar 20, 2026

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

  1. 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 "$@"; }
``

  1. Verify it works in a normal terminal: ll → works
  2. Verify it works via Claude's Bash tool (asking Claude to run ll) → works
  3. Use !ll in 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.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗