Skip to content

Shell Hooks

envpkt provides shell hooks that display credential health automatically when you navigate into a directory containing envpkt.toml.

Add to ~/.zshrc:

Terminal window
eval "$(envpkt shell-hook zsh)"

Add to ~/.bashrc:

Terminal window
eval "$(envpkt shell-hook bash)"

The hook wraps the cd command. When you cd into a directory containing envpkt.toml, it runs:

Terminal window
envpkt audit --format minimal

This provides a one-line health summary without interrupting your workflow.

The envpkt shell-hook command outputs a shell function. For zsh, it looks approximately like:

Terminal window
envpkt_chpwd() {
if [[ -f envpkt.toml ]]; then
envpkt audit --format minimal 2>/dev/null
fi
}
chpwd_functions=(${chpwd_functions[@]} envpkt_chpwd)

For bash, it uses PROMPT_COMMAND or wraps cd.

In addition to ambient health warnings, you can source envpkt-managed secrets directly into your shell session using envpkt env export:

Terminal window
# Add to ~/.zshrc or ~/.bashrc
eval "$(envpkt env export 2>/dev/null)"

This resolves secrets via sealed packets and/or fnox and emits export KEY='VALUE' statements. Warnings go to stderr so they don’t interfere with eval.

You can combine both hooks for a complete setup:

Terminal window
# Shell startup
eval "$(envpkt shell-hook zsh)" # Ambient health on cd
eval "$(envpkt env export 2>/dev/null)" # Load secrets into current session

See envpkt env export for full options.

  • Daily development — see credential health at a glance
  • Multi-project work — catch issues as you switch between projects
  • Team onboarding — new team members see credential status immediately