Skip to content

⚑ Auto-Full Bundle Mode¢

πŸ“‹ Auto-Full mode (ZSHAND_AUTO_FULL=1) automatically compiles and loads a single bundle containing all framework + user code. No manual compilation steps β€” it just works.


πŸš€ Quick SetupΒΆ

Add to ~/.zshenv (not env.zsh or .zshrc):

export ZSHAND_AUTO_FULL=1

Or use the template:

cp ~/code/zshand/samples/zshenv/zshenv.template ~/.zshenv

Start a new shell. First run auto-compiles:

πŸ”¨ Auto-compiling full bundle (first run)...
β†’ Compiling zshand-full.zwc...
βœ“ Full bundle compiled successfully

Every subsequent shell start loads the cached bundle silently.

Must be ~/.zshenv

This flag must be set in ~/.zshenv because it's checked before the framework loads. Setting it in ~/.config/zshand/env.zsh creates a circular dependency (that file is inside the bundle).


πŸ”„ How It WorksΒΆ

Shell starts β†’ zshrc.zsh
  β”‚
  β”œβ”€ FAST PATH (bundle cached)
  β”‚    Check ZSHAND_AUTO_FULL=1 + bundle file exists?
  β”‚    β†’ YES: source bundle β†’ done (~15-40ms)
  β”‚
  └─ STANDARD PATH (first run or bundle missing)
       Load build functions β†’ compile bundle β†’ source bundle (~200-500ms)
       β”‚
       └─ FALLBACK (compile fails)
            Standard hybrid loading proceeds β†’ shell still works

Guard conditions (all must be true for auto-full):

  • ZSHAND_AUTO_FULL=1
  • ZSHAND_DEV_MODE=0 (not in dev mode)
  • ZSHAND_AUDIT_MODE=0 (not in audit mode)

πŸ“¦ What's in the BundleΒΆ

The compiled bundle includes everything in the correct load order:

# Component Source
1 🧱 Shared functions shared_functions/
2 πŸš€ Startup scripts startup/
3 🌍 User environment env.zsh, secrets.zsh, config.toml
4 πŸ”§ User init scripts init.d/*.zsh (sorted)
5 πŸ›€οΈ PATH injection Compile-time from path.txt
6 βš™οΈ Core + overrides Framework core/ + user rc.d/ (merged)
7 πŸ› οΈ Functions Framework + user (merged)
8 ⌨️ Widgets Framework + user (merged)
9 πŸͺ¨ Hooks Framework + user (merged)
10 πŸ” Private functions private_functions/
11 πŸ“ Aliases aliases.zsh
12 🏁 Post scripts post.d/*.zsh (sorted)

πŸ”€ Override SemanticsΒΆ

User files with the same basename completely replace framework files:

~/.config/zshand/functions/seek.zsh  β†’  overrides $ZSHAND/functions/seek.zsh
~/.config/zshand/widgets/aicmit.zsh  β†’  overrides $ZSHAND/widgets/aicmit.zsh
~/.config/zshand/rc.d/14_aliases.zsh β†’  overrides $ZSHAND/core/14_aliases.zsh

Files with unique basenames are added alongside framework files.


⚑ Performance¢

Scenario Time Notes
πŸ”¨ First run (compiles) ~200–500ms One-time cost
⚑ Subsequent runs (cached) ~15–40ms Fast path β€” no build functions loaded
πŸ“‚ vs. Hybrid loading ~50% faster No per-directory compilation checks
πŸ”§ vs. Dev mode ~10Γ— faster No individual file sourcing

The fast path skips loading build infrastructure entirely when the bundle is already cached, saving ~10ms per shell start.


πŸ”„ When to RecompileΒΆ

The bundle is compiled once and reused. Recompile when you change anything:

# After modifying user config (aliases, functions, hooks, etc.)
zrecompile user

# After updating the framework (git pull)
zrecompile framework

# After changing both
zrecompile both

# Full manual rebuild
zfull

Or delete the cache and let auto-full recompile on next start:

rm ~/.cache/zshand/zshand-full.{zsh,zwc}
exec zsh

πŸ“Š Comparison with Other ModesΒΆ

Mode Trigger Contents Best For
Auto-Full (ZSHAND_AUTO_FULL=1) Automatic Framework + user Zero-config production
Manual Full (ZSHAND_USE_MONOLITHIC=1 + zfull) Manual Framework + user Explicit control
Framework-Only (ZSHAND_USE_MONOLITHIC=1 + zprime) Manual Framework only Testing / minimal
Hybrid (default) Automatic Framework + user Balanced / development
Dev Mode (.dev file or dirty git) Automatic Sources raw .zsh Active development

🚫 When It's Skipped¢

Auto-full is automatically bypassed in these situations:

  • Dev mode β€” ZSHAND_DEV_MODE=1 or .dev file exists (you want raw file loading)
  • Audit mode β€” ZSHAND_AUDIT_MODE=1 (needs full recompile + test cycle)
  • Explicitly disabled β€” ZSHAND_AUTO_FULL=0 or unset

πŸ”§ TroubleshootingΒΆ

Bundle fails to compileΒΆ

βœ— Auto-compilation failed. Falling back to standard loading.

Causes: Missing config directory, syntax errors in user files, disk full.

Fix:

  1. Check config dir exists: ls -la ~/.config/zshand
  2. Test compilation manually: zfull
  3. Check syntax: zsh -n ~/.config/zshand/rc.d/*.zsh

Functions missing after adding new filesΒΆ

The bundle was compiled before you added the files. Recompile:

zrecompile user    # or: zfull
exec zsh

Want fresh bundle every startΒΆ

Don't use auto-full. Instead:

# In ~/.zshenv
export ZSHAND_USE_MONOLITHIC=1

# Then manually run before each session:
zfull && exec zsh

Document Purpose
πŸ—οΈ ARCHITECTURE.md Bundle system and loading modes
⚑ PERFORMANCE.md Profiling and benchmarking
πŸ‘€ USER_CONFIG.md User configuration directory
πŸ”§ TROUBLESHOOTING.md Bundle troubleshooting
πŸ“‚ build/README.md Build system details