This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
ZMETA is a modular, cross-platform shell configuration system built on zsh and zinit. It provides platform-specific and hardware-specific configuration management with XDG Base Directory compliance.
~/.zmeta/
├── .zshenv # Environment variables (sourced by all zsh instances)
├── .zshrc # Main zsh configuration with zinit plugin management
├── aliases.zsh # Global shell aliases
├── aliases-{Darwin,Linux}.zsh # OS-specific aliases
├── lib/
│ └── xdg.zsh # XDG Base Directory Specification setup
├── hosts/
│ ├── platforms/ # OS + architecture combinations
│ │ ├── _core/ # Shared platform initialization
│ │ ├── darwin-arm64/
│ │ ├── linux-aarch64/
│ │ └── linux-x86_64/
│ └── hardware/ # Machine-specific configs (by hostname)
│ ├── m1/, m3/, obs/, nzt/, etc.
├── bin/ # Utility scripts and tools
├── shells/
│ └── fish/ # Fish shell integration (isolated from zsh)
├── functions/ # Shell functions
├── tests/ # Bats test suite
└── zinit/ # Zinit plugin manager (git submodule)
The shell initialization follows this order:
.zshenv- Sets core environment variables, ZMETA paths, detects platform- Platform detection → sources
hosts/platforms/{os}-{arch}/init.zsh - Platform init → sources
hosts/platforms/_core/init.zsh .zshrc- Loads zinit, plugins, completions, and theme- Hardware-specific config loaded if hostname matches directory in
hosts/hardware/ - User aliases and functions sourced last
Platforms are auto-detected as {os}-{arch} (e.g., darwin-arm64, linux-x86_64). Each platform can define:
init.zsh- Platform initialization and environment setupessence/- Directory synced to~/.config/for platform-specific app configsDARWIN_ARM64_CONFIGSor similar associative arrays for lazy-loaded configs
Machine-specific configs are stored in hosts/hardware/{hostname}/ and typically contain:
aliases.zsh- Machine-specific command aliases- Additional host-specific configuration files
The .zshrc uses zinit extensively for:
- Oh-My-Zsh and Prezto plugins as snippets
- GitHub releases as binaries (fd, bat, ripgrep, etc.)
- Completions for various tools
- Fast-syntax-highlighting and autosuggestions
- Pure prompt theme
# Run all tests using bats
./tests/run_tests.sh tests/*.bats
# Run specific test suite
bats tests/platform_detection.bats
# View test output
cat tests/output/test_results.tap # TAP13 format
cat tests/output/summary.txt # Human-readable summaryTest coverage includes:
- Platform detection (OS/architecture)
- Hardware detection (hostname-based)
- Environment setup (PATH, XDG directories)
- Essence copying (config inheritance)
- Alias management
Use the cohere script to regenerate platform/hardware directories:
# Source the cohere function
source ~/.zmeta/bin/cohere
# Run to create directory structure
cohereThis creates all platform and hardware directories defined in the script.
- Add platform to
bin/coherein theplatformsarray - Run
cohereto create directory structure - Create
hosts/platforms/{new-platform}/init.zsh - Add platform-specific PATH, environment variables, and configs
- Add hostname to
bin/coherein thehardware_namesarray - Run
cohereto create directory structure - Create
hosts/hardware/{hostname}/aliases.zshwith machine-specific aliases
# Run 10 startup benchmarks
zbench
# Or manually
for i in {1..10}; do /usr/bin/time zsh -lic exit; done# Install fish config (symlinks to ~/.config/fish/)
~/.zmeta/shells/fish/install.sh
# Run fish integration tests
~/.zmeta/shells/fish/tests/run_tests.sh allAll XDG directories are set up in lib/xdg.zsh with platform-specific runtime directory handling:
- macOS: Uses
$TMPDIR/runtime-$(id -u) - Linux: Uses
/run/user/$(id -u)with fallback
Zinit is configured to use:
$HOME/.local/share/zsh/zinitas the base directory- Optimized disk access with
ZINIT[OPTIMIZE_OUT_DISK_ACCESSES]=1 - Completion caching in zinit's completions directory
Key variables set in .zshenv:
ZMETA- Path to this repository ($HOME/.zmeta)ZDOTDIR- Points to$ZMETA(makes zsh look here for configs)ZINIT_HOME- Zinit installation directoryGOPATH- Go workspace pathOLLAMA_MODELS,OLLAMA_HOST- Ollama configuration
- Static zsh binary from romkatv/zsh-bin
- Oh-My-Zsh and Prezto snippets
- Completions
- Tool-specific plugins (kubectl, docker, etc.)
- Pure prompt
- zsh-vim-mode
- GitHub release binaries
- Syntax highlighting (loaded last)
- Final cleanup with
zicompinitandzicdreplay
bin/cohere- Directory structure generatorbin/argon2_hashgen.py- Argon2 password hash generatorbin/authelia-gensecs.sh- Authelia secret generationbin/choices/bin/choice- Interactive menu selectiontests/run_tests.sh- Bats test runner with output formatting
Uses bats-core with helper libraries (git submodules):
bats-support- Test helpersbats-assert- Assertion functionsbats-file- File/directory assertions
Test files use common setup functions from tests/test_helper/common-setup.bash.
Binary tools from GitHub releases:
- Search/Find: fd, ripgrep, fzf, grex
- Viewers: bat, hexyl, delta (git diff)
- Benchmarking: hyperfine, bottom
- Editors: neovim, helix
- Dev Tools: jq, shellcheck, shfmt
- Kubernetes: kubectl-fzf, arkade
- Package Managers: aqua, uv (Python)
- Shell Tools: direnv, vivid (LS_COLORS)
Fish shell configuration is completely isolated in shells/fish/ and installed separately to ~/.config/fish/. It does not interfere with zsh configuration.
Initialize submodules after cloning:
git submodule init
git submodule updateActive submodules:
test_helper/bats-supporttest_helper/bats-asserttest_helper/bats-filezinit/(zinit plugin manager)
Zsh uses vim mode with visual indicators:
- Mode indicators: INSERT (green), NORMAL (cyan), VISUAL (blue), REPLACE (red)
- Cursor changes per mode (blinking bar in insert, block in normal)
KEYTIMEOUT=1for fast mode switching- Edit command line in vim with
Ctrl-ein vicmd mode
See aliases.zsh, aliases-Darwin.zsh, or aliases-Linux.zsh for full list. Notable ones:
gac- Git add all and commitll,la,l- Various listing formats using lsd/ezacleanup- Platform-specific cleanup (brew cleanup on macOS)zbench- Benchmark zsh startup timehashpass- Generate Argon2 password hash