Skip to content

testinit - Shell Initialization Test Harness

Runs full Zshand initialization (sources zshrc.zsh) without starting an interactive shell. Use it to debug startup, validate config changes, or time init.

Overview

testinit sets ZSHAND from the script path if needed, then sources ${ZSHAND}/zshrc.zsh. It exits 0 if init succeeds and non-zero if the framework path or zshrc is missing or if sourcing fails.

When to use: Debug startup performance, check that config/plugins load without errors, or benchmark init (e.g. time testinit).

Usage

testinit [-h|--help]

Options

  • -h, --help — Show help (to stderr) and exit.

No other options. The script only sources the main zshrc and exits.

Examples

# Test that init completes
testinit

# Check result
testinit && echo "Init OK" || echo "Init failed"

# Time initialization
time testinit

How It Works

  1. ZSHAND — If unset: set from dirname "$0"/.., or from ZSHAND_HOME / $HOME/code/zshand when HOME is set.
  2. Validation — Exit 1 if ZSHAND is still empty or if ${ZSHAND}/zshrc.zsh is not a file.
  3. Sourcesource "${ZSHAND}/zshrc.zsh". If source returns non-zero, print error and exit 1.
  4. Exit — Exit 0 on success.

Configuration

No config file. Behavior depends on:

Variable / path Effect
ZSHAND Framework root; script uses this if set.
ZSHAND_HOME Fallback when ZSHAND is unset and script path cannot be used.
HOME Used for fallback path $HOME/code/zshand when ZSHAND is unset.

Dependencies

  • ZSHAND (or resolvable from script path / ZSHAND_HOME / HOME).
  • ${ZSHAND}/zshrc.zsh must exist and be valid zsh (no syntax errors).

Troubleshooting

"ZSHAND could not be determined"

Set ZSHAND to the framework root, or run testinit from the repo so the script can derive it from its own path. If HOME is unset, the fallback path cannot be used.

"Not found: .../zshrc.zsh"

The script resolved ZSHAND but zshrc.zsh is missing there. Fix ZSHAND or install the framework so that zshrc.zsh exists under the framework root.

"Initialization failed (source returned error)"

Sourcing zshrc.zsh returned non-zero (e.g. syntax error or a sourced file failed). Check stderr for the actual error and fix the reported file or config.

See Also

  • zshrc.zsh — Main entry point that testinit sources.
  • core/02_vars.zsh — Early framework vars and config loading.
  • Testing Guide — How to run the test suite.