// ZSHRS — THE FIRST COMPILED UNIX SHELL

zshrs v0.11.46 · Anti-fork architecture · 23 coreutils builtins · VM-executed parallel · Bytecode caching · JIT · Full reference · Daemon impl map

// Color scheme

>_ZSHRS REFERENCE

The most powerful shell ever created. No-fork architecture, AOP intercept, worker thread pool, bytecode caching, fusevm compiled execution.

SHELL SCRIPTS AT MACHINE CODE SPEED.

NO FORK. NO INTERPRETER. JUST BYTECODES.

0
forks in hot path
100%
bytecode compiled
18
worker threads
180+
builtins
23
coreutils builtins
100x
warm start speedup
2000x
fork avoidance speedup
1st
compiled Unix shell

For the first time in the history of computing — since the dawn of Unix at Bell Labs in 1970 — a shell compiles to executable bytecodes and runs them on a virtual machine with fused superinstructions. Every interactive command line, every shell script, every function invocation, every source’d file compiles to fusevm bytecodes and executes at near-machine-code speed. No tree-walking interpreter. No fork. No parsing at runtime if bytecodes are cached.

Compiled bytecodes are cached as rkyv zero-copy archives mmap'd directly into memory. Function invocations deserialize cached bytecodes in microseconds — skipping the lexer, parser, and compiler entirely. source’d scripts and interpreted scripts follow the same path: compile once, cache, execute from bytecode forever. This has never been achieved in a Unix shell.

[0x00a] INVENTIONS — THE LIST

This is a legacy, not a battle. Every item below originated in zshrs and is offered as prior art for the shell-design commons under the MIT grant. Future shells (bash, fish, nushell, elvish, oil, xonsh, murex, projects that don’t exist yet) should inherit any of it. Ports must credit zshrs as the invention source in their docs — see CREATORS.md for the suggested wording. The protected invariants in MAINTAINERS.md guard upstream identity, not the ideas.

Compiled Unix shell

First Unix shell to compile every command (interactive, script, function, sourced file) to bytecode and execute on a purpose-built VM. Every shell since Bell Labs 1970 has been an interpreter.

fusevm bytecode VM

NaN-boxed register VM with fused superinstructions and a Cranelift JIT for hot blocks. Shared substrate with stryke so a shell and a scripting language ride the same value representation.

Zsh grammar introspection to stdout

First shell to emit, in canonical diffable formats, zsh’s lexer token stream, wordcode (Eprog) layout, and a structured parser AST (S-expression) — the zshrs binary (--dump-tokens, --dump-wordcode, --dump-ast) and the matching zshrs_dump loadable module (dumptokens, dumpwordcode). Stock zsh does not ship this trio as a user-facing pipeline.

Fusevm bytecode on argv (--disasm)

The zshrs binary prints the fusevm op listing (name pool, subroutine entries, each opcode, nested sub_chunks) to stdout before every VM run — the IR the shell actually executes, next to the lexer/AST/wordcode dump trio. Stock zsh does not expose its internal wordcode VM stream on argv this way.

Persistent worker thread pool

18 (configurable [2-18]) tokio threads owned by the shell. $(cmd), <(cmd), &, globbing, completion, autoloading all dispatch to the pool instead of fork(2). Zero forks in the hot path.

90/10 daemon / shell split

Singleton zshrs-daemon owns every mutation (canonical state, fsnotify, schedule, jobs, locks, cache, history). Thin shell clients are stateless and forkable. No shared writer, no second process tree, no auto-spawn.

Recorder-owns-rebuild (AOP intercept)

zshrs-recorder AOP-intercepts every state-mutating dispatcher at runtime — alias / function / export / fpath edit / hash -d / zstyle / bindkey / compdef / zmodload / setopt / trap / sched / source / assignment — and ships (kind, name, value, file, line, fn_chain) to the daemon. Replaces the static-walker approach every other shell uses for completion / fpath scanning.

rkyv canonical-state shards

Daemon's in-memory canonical state persists as content-addressed rkyv archives under ~/.zshrs/images/. Cold-start shells mmap the shard and skip every dotfile in /etc + ~. ~10ms cold-start vs >100ms re-source.

Single ~/.zshrs/ directory rule

Every config + log + sqlite + rkyv shard + socket lives under one root. $ZSHRS_HOME overrides for sandboxes / hermetic harnesses. rm -rf ~/.zshrs/ is the one-verb total reset.

Three log files, one per binary

zshrs.log (shell) + zshrs-daemon.log + zshrs-recorder.log — never interleaved. One paths::is_zshrs_log_file matcher feeds rotation, tail, clear, snapshot bundling.

Three TOML configs, all auto-seeded

zshrs.toml + zshrs-daemon.toml + zshrs-recorder.toml with documented defaults. Every binary seeds the dir on first run; idempotent across all four. Auto-migrates legacy daemon.tomlzshrs-daemon.toml.

z* builtin family

One namespace, twenty-three builtins, one daemon route. zcache, zls, zid, zping, ztag, zsend, znotify, zsubscribe, zjob, zsync, zask, zhistory, zsource, zcomplete, zsuggest, zlog, zwhere, zd, zlock, zpublish.

Cross-shell pub/sub + named locks

zsubscribe / zpublish / zlock as builtins routed through the singleton daemon. Replaces flock + socat + named pipes glued by hand. Locks are token-issued; release requires the original token (lost shell can’t accidentally release someone else’s lock).

Session-persistent supervised jobs

zjob submit spawns under the daemon — survives shell exit, output captured to disk, status persisted in catalog.db, history survives daemon restarts. Replaces nohup + screen + pueue + disown.

Bidirectional ptmx zjob attach

--pty submit allocates a pseudo-terminal pair; child runs with slave on 0/1/2. zjob attach switches client termios to raw mode, pumps stdin via job_input (base64), drains daemon broadcast back to user’s tty, propagates SIGWINCH via job_resize. Ctrl-] detaches; job keeps running. Solves bg-jobs-blocked-on-stdin.

Auto-derived OpenAPI 3.1

GET /openapi serves a spec-compliant OpenAPI doc generated on every request from the daemon’s op registry (OP_NAMES). 108 paths today (4 meta + 101 ops + 3 stream routes). bearerAuth declared only when [http.tokens] is populated. Loopback bind requires no token; non-loopback bind refuses without one.

Daemon HTTP listener default-on (loopback)

Seeded zshrs-daemon.toml ships [http] listen = "127.0.0.1:7733" so zd health works out of the box. Same trust model as the Unix socket on a single-user box; flips to required-auth the moment the bind goes non-loopback.

zd — HTTP bin AND in-process builtin

Same arg surface, two transports. zd the binary uses ureq against the HTTP listener (works from bash / fish / CI / curl). zd the builtin inside zshrs uses the local Unix socket via the daemon Client — 5.5× faster (0.48ms vs 2.64ms, no fork).

zd doctor

One-command health sweep: cache-root perms, file-perms drift, pidlock liveness, socket presence, catalog integrity (sqlite PRAGMA integrity_check), shards-present count, fsnotify-alive, supervised-job count, legacy-litter scan (~/.zcompdump*, ~/*.zwc). Pretty ASCII table; non-zero exit on any FAIL.

Flat history + sibling FTS5 sqlite

~/.zshrs/zshrs_history (flat zsh-extended-history text, cat-able and grep-able) + ~/.zshrs/zshrs_history.db (FTS5 index for fast search / dedup / frequency). The writer keeps both in lockstep; on open, the text mirror is rehydrated from the index if stale. Auto-migrates the legacy ~/Library/Application Support/zshrs/history.db.

Recorder sources the full 8-file login chain

zshrs-recorder by default mirrors a real zsh -l -i: /etc/zshenv, ${ZDOTDIR:-$HOME}/.zshenv, /etc/zprofile, ~/.zprofile, /etc/zshrc, ~/.zshrc, /etc/zlogin, ~/.zlogin. Missing files skipped silently. $ZDOTDIR re-resolved per file.

zsync up --all

Single command snapshots every overlay table (alias / galias / salias / setopt / params / env / path / manpath / fpath / named_dir / compdef / zstyle) and pushes into the daemon’s canonical state. Shell-side overlay_snapshot::enumerate_all_overlays registered via fn-pointer trampoline so the daemon crate stays decoupled from ShellExecutor.

23 anti-fork coreutils builtins

cat, head, tail, wc, sort, find, uniq, cut, tr, seq, rev, tee, sleep, date, mktemp, hostname, uname, whoami, id, basename, dirname, touch, realpath. All in-process; one cat in a pipeline doesn’t fork.

Parallel-as-syntactic-primitive

fish-style parallel iterators (par_for, par_map, par_filter, par_reduce) ship as VM opcodes, not library calls. Glob walks parallelize at depth ≥ 32 by default. Worker pool is the substrate.

The --no-fork philosophy as a measurement

Every accepted commit is graded by “does this remove a fork?” not “does this add a feature?” Optimization layers (zinit turbo, p10k instant prompt, zwc, zcompile, BG_NICE, lazy autoload) are evidence that zsh can’t solve the problem in userspace; zshrs accepts the architecture cost to solve it for real.

First shell with native LSP server + DAP debug adapter

World’s first shell to ship Language Server Protocol and Debug Adapter Protocol as first-class subsystems of the shell binary itself. zshrs --lsp starts an LSP server on stdio (completion, hover, documentSymbol, foldingRange, semanticTokens, formatting, rename, diagnostics) consumed by any editor — JetBrains, VS Code, Helix, Neovim. zshrs --dap HOST:PORT speaks the full Debug Adapter Protocol over TCP (breakpoints, stepping, frames, scopes, variables, evaluate) so any DAP client can debug zsh scripts. No other shell (bash, zsh, fish, nu, elvish, oil, xonsh, murex) ships either — bash-language-server is a Node-based third-party project, not part of bash; no zsh equivalent exists at all. The JetBrains plugin at editors/intellij/ drives both, and additionally surfaces every sourced zsh plugin (zinit / oh-my-zsh / prezto / antidote / antigen / zplug / zsh-more-completions / zpwr / loose) under the IDE’s External Libraries node via zshrs --dump-plugins — cmd-clickable, find-usages-able, rename-across-plugin-boundary, indexed once per project. No other shell exposes its plugin-manager state as IDE library roots; the closest precedents (bash-language-server, fish-shell.vscode) ignore plugin managers entirely. Hand-rolled JSON-RPC framing, zero new dependencies.

First POSIX-compatible shell with a builtin unit-test framework

World’s first POSIX-compatible shell to ship a unit-test framework + worker-pool runner in the binary, zero external install. zassert_eq / zassert_ne / zassert_ok / zassert_gt / zassert_lt / zassert_match / zassert_contains / zassert_near / zassert_dies — 14 assertion verbs — plus ztest_skip and ztest_run (alias run_tests) are shell builtins, callable from any .zsh / .sh script with no npm i, gem install, or cargo install step. zshrs --ztest [paths…] runs a worker-pool: N persistent --ztest-worker subprocesses (one per CPU) fork-on-receive per test, JSON-over-pipe wire protocol, per-test fd 2 capture so concurrent workers never tear each other’s output — the same architecture cargo-nextest brought to Rust testing, now in a shell binary. Every other POSIX-family shell (bash, zsh, ksh, dash, fish) relies on third-party packages installed separately: bats-core, shunit2, Bach, ShellSpec, zunit, korn-spec. PowerShell’s Pester (preinstalled on Windows 10+) is the closest precedent, but PowerShell is not POSIX. Nushell ships std assert builtins but is its own non-POSIX language and has no integrated runner. Lives in src/extensions/ztest.rs; port of strykelang’s stryke test runner.

Full enumeration + suggested attribution wording in CREATORS.md. Op-by-op detail in daemon-report.html. Port-coverage report in report.html.

[0x00] THE COMPILATION PIPELINE

Every path through zshrs ends at the same place: fusevm bytecode execution.

┌─────────────────────────────────────────────────────────────────┐ │ THREE EXECUTION PATHS │ │ │ │ ┌─────────────┐ Interactive command line │ │ │ REPL Input │──► Parser ──► ShellCompiler ──► fusevm::Op │ │ └─────────────┘ │ │ │ ▼ │ │ ┌─────────────┐ Shell script / source file VM::run() │ │ │ Script File │──► Parser ──► ShellCompiler ──► │ │ │ └─────────────┘ │ │ │ │ └──► rkyv image ──────────┘ │ │ (cached on first compile) │ │ │ │ ┌─────────────┐ Autoload function (compinit) │ │ │ rkyv image │──► mmap zero-copy archive ──► fusevm::Chunk ──►│ │ │ shard │ (no lexer, no parser, VM::run() │ │ └─────────────┘ no compiler — microseconds) │ └─────────────────────────────────────────────────────────────────┘
PathLexParseCompileExecuteCache
Interactive commandYesYesYesfusevmNo (ephemeral)
Script file (first run)YesYesYesfusevmYes → rkyv
Script file (cached)NoNoNofusevmHit → deserialize
Autoload function (cached)NoNoNofusevmHit → deserialize
Plugin source (cached)NoNoNofusevmDelta replay → µs

[0x01] ARCHITECTURE

zshrs Architecture ┌─────────────────────────────────────────────────────┐ │ REPL / ZLE │ │ reedline + syntax highlighting + autosuggestions │ └──────────────────────┬──────────────────────────────┘ │ ┌──────────────────────▼──────────────────────────────┐ │ ShellExecutor (18K lines) │ │ parser ─► compiler ─► fusevm bytecode dispatch │ │ 180+ builtins │ AOP intercept │ trap/signal │ └──────┬─────────┬─────────┬─────────┬────────────────┘ │ │ │ │ ┌──────▼───┐ ┌───▼────┐ ┌─▼──────┐ ┌▼──────────────┐ │ Worker │ │ rkyv │ │ fusevm │ │ compsys │ │ Pool │ │ images │ │ VM │ │ completion │ │ [2-18] │ │ + │ │ │ │ engine │ │ threads │ │catalog │ │ Op enum│ │ │ │ │ │ .db │ │ fused │ │ MenuState │ │ glob │ │(query) │ │ super- │ │ MenuKeymap │ │ rehash │ │bytecode│ │ instr │ │ rkyv shards │ │ compinit │ │mmap'd │ │ JIT ► │ │ │ │ history │ │ shards │ │Cranelft│ │ │ └──────────┘ └────────┘ └────────┘ └───────────────┘

Source-tree layout: ported / extensions / recorder split

The runtime crate is physically split so port code and original code can never be confused. Bots, contributors, and humans all read docs/PORT.md before writing a single line of code; tests/port_purity.rs mechanically enforces the rules in CI.

  • src/ported/ — 107 files, FROZEN. Strict 1:1 port. Every .rs mirrors a real src/zsh/Src/<x>.c file (same stem, same relative subpath). Every top-level fn carries a /// Port of <cname>() from Src/<file>.c:NNNN doc-comment. New file creation is banned; new fn names that don't exist in upstream zsh C source are banned. The freeze closes both drift vectors: bots invent helper names ("shell_quote", "find_in_path") and bots create fresh files to drop helpers in. Both blocked.
  • src/extensions/ — 40 files. The non-port directory. Features zsh C demonstrably does not have: AOT (aot.rs, compile_zsh.rs), autoload/plugin/script caches, fish-style autosuggest/abbrev/highlight, persistent worker pool, arith JIT, AST s-exp dump, ZWC byte-code helpers, recorder hooks, daemon presence, structured logging, ZLE keymaps/widgets, ext builtins, regex module, config, overlay snapshot + canonical apply, subscript/fds/hist extensions. port_purity exempts this directory from the 1:1 file-existence rule on the basis that no C ancestor exists.
  • src/recorder/ — 1 file, feature-gated. Every symbol #[cfg(feature = "recorder")]; deleted by rustc when the feature is off. Compiled into the separate zshrs-recorder binary, never the default zshrs build.
  • src/zsh/ — vendored upstream. Read-only reference. The C spec; never modified.

Lexer + parser ports live in src/ported/lex.rs and src/ported/parse.rs (no separate parse/ crate). Workspace sibling: daemon/ (41 files, zshrs-daemon); compsys was folded into the main zshrs crate (no longer a standalone sibling). Top-level dirs: fish/ (157 files, fish-style reader/highlighter/abbreviations), bins/ (4 entry points: zshrs, zshrs-recorder with required-features = ["recorder"], zd with required-features = ["zd"], bench-autoload). 609 .rs files total · 645,344 Rust LOC (git ls-files '*.rs' | xargs wc -l, 2026-06-05). Test count: 14,552 #[test] markers across the tree.

[0x01] ANTI-FORK ARCHITECTURE

Every fork is a full process copy. On macOS, fork() costs 2-5ms including exec + ld.so + libc init. zsh forks for every $(...), <(...), cat, grep, subshell, and completion. zshrs forks for none of them.

OperationzshzshrsSpeedup
cat filefork + exec /bin/catBuiltin — zero fork2000-5000x
head/tail/wcfork + execBuiltin — zero fork2000-5000x
sort/find/uniqfork + execBuiltin — zero fork2000-5000x
date/hostname/unamefork + execDirect syscall3000-8000x
sleep/mktemp/touchfork + execBuiltin — zero fork2000-5000x
xattr operationsfork + exec xattrDirect syscall2000-5000x
pmap/pgrep/peachfork N times to sh -cVM execution — zero forkNx
$(cmd)fork + pipe + execIn-process stdout capture via dup2
<(cmd) / >(cmd)fork + FIFOWorker pool thread + FIFO
Glob **/*.rsSingle-threaded opendirParallel walkdir per-subdir on pool
rehashSerial readdir per PATH dirParallel scan across pool
Autoload functionRead file + parse every timeZero-copy mmap of rkyv-archived bytecode (µs)100x

Coreutils Builtins (23 commands, zero fork)

cat head tail wc sort find uniq cut tr seq rev tee basename dirname touch realpath sleep whoami id hostname uname date mktemp

Every invocation of these commands is 2000-5000x faster than forking to the external binary.

[0x02] WORKER THREAD POOL

Persistent pool of warm threads. Bounded crossbeam channel with backpressure. Panic recovery keeps workers alive. Task cancellation on Ctrl-C. Instant shutdown on exit.

# ~/.zshrs/zshrs.toml (seeded on first run; idempotent) [log] level = "info" # env $ZSHRS_LOG overrides; "trace" prints startup diagnostics [shell] skip_configs = "auto" # when daemon up + canonical shard recorded, skip /etc/zsh{env,rc} + ~/.{zshenv,zprofile,zshrc,zlogin} [worker_pool] size = 8 # 0 = auto (num_cpus clamped [2, 18]) [completion] bytecode_cache = true # compile autoload functions to fusevm bytecodes [history] async_writes = true # daemon-side writes via IPC; prompt never blocks [glob] parallel_threshold = 32 # min files before parallel metadata prefetch recursive_parallel = true # fan out **/ across worker pool

Tasks shipped to the pool:

compinit

Background fpath scan + bytecode compilation of 16K+ functions

Process Sub

<(cmd) and >(cmd) on pool threads instead of fork

Parallel Glob

**/ recursive walk split per-subdir across pool

Metadata Prefetch

Glob qualifiers: one parallel stat batch, zero syscalls after

PATH Rehash

Parallel readdir across every PATH directory

History Writes

Daemon-side writes via IPC — prompt never waits, zero client SQLite handle

[0x03] AOP INTERCEPT

The first shell ever with aspect-oriented programming. Hook before, after, or around any command or function — at machine code speed, no fork. One primitive that replaces defer, profile, memo, retry, and timeout.

# Before — log every git command intercept before git { echo "[$(date)] git $INTERCEPT_ARGS" >> ~/git.log } # After — show timing for completion functions intercept after '_*' { echo "$INTERCEPT_NAME took ${INTERCEPT_MS}ms" } # Around — memoize expensive function intercept around expensive_func { local cache=/tmp/cache_${INTERCEPT_ARGS// /_} if [[ -f $cache ]]; then cat $cache else intercept_proceed | tee $cache; fi } # Around — retry with backoff intercept around flaky_api { repeat 3; do intercept_proceed; [[ $? == 0 ]] && break; sleep 1; done } # Fat binary — stryke code at machine code speed intercept after 'make *' { @pmaps { notify "done: $_" } @(slack email) }

Variables available in advice:

VariableAvailableDescription
$INTERCEPT_NAMEallCommand name
$INTERCEPT_ARGSallArguments as space-separated string
$INTERCEPT_CMDallFull command string
$INTERCEPT_MSafterExecution time in milliseconds (nanosecond source)
$INTERCEPT_USafterExecution time in microseconds
$?afterExit status

[0x04] RKYV ZERO-COPY CACHE LAYER

Cached bytecode lives in rkyv archives mmap'd by clients — zero-copy deserialization, no allocator pressure on hot paths. The daemon owns all writes; clients only mmap. The single queryable mirror is catalog.db (SQLite) for dbview introspection — never touched on the hot path.

images/{hash}-{slug}.rkyv

Per-source-root rkyv shards. Compiled bytecode for autoloads, plugins, sourced scripts. Daemon writes; clients mmap zero-copy. Validates with rkyv's bytecheck on first access; format-versioned for migration safety.

index.rkyv

Top-level shard index: source-root path → shard hash + mtime. Daemon rewrites on changes; clients mmap to resolve which shard to load.

catalog.db (SQLite mirror)

Daemon-hydrated FTS5-indexed mirror of all rkyv contents. Used ONLY by dbview and zcache introspection — never read on the hot path. Clients have ZERO SQLite handles. The daemon's own FTS5 history (history.db) sits next to it; the shell's user-facing history is zshrs_history (flat zsh-extended-history-format text) plus a sibling FTS5 index zshrs_history.db, both in $ZSHRS_HOME.

Browse caches without SQL:

dbview # list all tables + row counts (hits catalog.db) dbview autoloads # dump autoloads: name, body size, ast size dbview autoloads _git # single row: source, body, ast status, preview dbview comps git # search comps for "git" dbview executables rustc # search PATH cache dbview history docker # search history zcache rebuild # force daemon to recompile every shard zcache verify # bytecheck every rkyv archive

[0x04b] FILE LAYOUT & BINARIES

One directory holds every zshrs file: $ZSHRS_HOME (defaults to ~/.zshrs/). All four binaries — zshrs, zshrs-daemon, zshrs-recorder, zd — seed the directory and three default configs on first run via CachePaths::ensure_default_configs. Idempotent — never overwrites user edits. Auto-migrates legacy daemon.tomlzshrs-daemon.toml and the legacy macOS history at ~/Library/Application Support/zshrs/history.db~/.zshrs/zshrs_history.db.

~/.zshrs/ ├── zshrs.toml # shell config [log] [daemon] [shell.skip_configs] ├── zshrs-daemon.toml # daemon config [log] [http] [http.tokens] ├── zshrs-recorder.toml # recorder config [log] ├── zshrs.log # shell tracing ├── zshrs-daemon.log # daemon tracing ├── zshrs-recorder.log # recorder tracing ├── zshrs_history # flat zsh-extended-history-format text ├── zshrs_history.db # FTS5 index sibling ├── catalog.db # daemon canonical-state mirror (FTS5) ├── history.db # daemon's own FTS5 history ├── cache.db # daemon KV cache ├── plugins.db ├── images/ # rkyv canonical shards (per source root) ├── replay/ # non-deterministic .zshrc fragments ├── artifacts/ # content-addressed artifact cache ├── snapshots/ # tag-based canonical-state snapshots ├── jobs/ # supervisor stdout/stderr captures ├── daemon.sock # Unix domain socket ├── daemon.pid # singleton flock └── index.rkyv # shard registry

Three log files (one per binary)

FileOwnerLevel source
zshrs.logshell[log] level in zshrs.toml (env $ZSHRS_LOG wins)
zshrs-daemon.logdaemon[log] level in zshrs-daemon.toml
zshrs-recorder.logrecorder[log] level in zshrs-recorder.toml

Helper paths::is_zshrs_log_file matches all three for rotation, tail, and clear. Default daemon startup emits 7 INFO lines; with level = "trace" an additional ~5 startup diagnostics print (resolved env, pidlock, db sizes, ticker spawn, schedule spawn, http listener address).

[shell] skip_configs = "auto"

When the daemon is up AND has a recorded zshrs canonical shard, the shell SKIPS sourcing /etc/zshenv + ~/.{zshenv,zprofile,zshrc,zlogin} entirely and rebuilds executor state from the rkyv shard. canonical_apply wires alias/galias/salias/env/params/setopt/path/fpath/named_dirs/autoload_functions/zstyle/bindkey/compdef/zle widgets. Inline functions are deferred until the recorder ships bytecode in the shard.

[0x04c] RECORDER (zshrs-recorder)

Separate binary — not a flag on zshrs. Sources the full zsh login chain in order, skipping any missing file silently:

1. /etc/zshenv 2. ${ZDOTDIR:-$HOME}/.zshenv 3. /etc/zprofile 4. ${ZDOTDIR:-$HOME}/.zprofile 5. /etc/zshrc 6. ${ZDOTDIR:-$HOME}/.zshrc 7. /etc/zlogin 8. ${ZDOTDIR:-$HOME}/.zlogin

-f PATH overrides the chain to source one file. End-of-run ships a recorder_ingest IPC bundle to the daemon, which folds it into the canonical shard for the matching source root.

[0x04d] zd — TWO SURFACES

SurfaceTransportLatencyUse case
zd binaryHTTP via ureq to [http].listen2.64 ms (fork+exec)bash, fish, CI, anything outside zshrs
zd builtin (in-process)local Unix socket via Client0.48 ms (5.5× faster)inside zshrs — same arg surface

Default HTTP listener: 127.0.0.1:7733, seeded into zshrs-daemon.toml on first run so zd health works out of the box. Default token comes from $DAEMON_TOKEN. Loopback bind requires no token; non-loopback bind refuses to start until [http.tokens] is populated. GET /openapi (alias /openapi.json) returns an OpenAPI 3.1 document auto-derived from OP_NAMES — 108 paths today (4 meta + 101 ops + 3 streams), with ErrPayload in components and bearerAuth declared only when tokens are configured.

zd subcommands

zd health # liveness probe zd ops # enumerate every op zd metrics # Prometheus exposition zd ping [echo...] zd info zd call OP [JSON_BODY] # raw op invocation zd doctor [--json] # pretty health table: perms, db integrity, shards, # fsnotify, pidlock, jobs, legacy litter; exit 1 on any fail zd config get KEY # runtime knob plumbing zd config set KEY VALUE zd config list zd snapshot save TAG [--notes N] # canonical-state freeze zd snapshot list zd snapshot load TAG zd snapshot diff A B zd cache <put|get|del|list|stats> zd job <submit|list|status|output|kill|cancel|wait> zd lock <try|acquire|release|list> zd publish TOPIC [DATA] [--json '...'] zd events / zd watch / zd defs zd artifact <put|get|list|gc> zd schedule <add|add-once|list|remove> zd export TARGET FORMAT [--json] # raw export — NO json envelope by default zd view TARGET [FORMAT]

zd export aliases pdf > out.pdf produces a real PDF — payload is streamed direct for sh / csv / json / yaml / text / pdf. --json opt-in restores the JSON envelope.

[0x04e] NEW z* BUILTINS

BuiltinDescription
zlock try NAMECross-process named lock — non-blocking try
zlock acquire NAME [--timeout S]Poll-wait acquire with optional timeout
zlock release NAME TOKENRelease by token
zlock listList all held locks
zpublish TOPIC / TOPIC DATA / TOPIC --json '{...}'Producer side of the pub/sub bus (consumer is zsubscribe)
zwhere SUBSYS NAMEQuery daemon canonical state for "where did this alias / function / zstyle come from" with file:line attribution

Full builtin family: zcache, zls, zid, zping, ztag, zuntag, zsend, znotify, zsubscribe, zunsubscribe, zjob, zsync, zask, zhistory, zsource, zcomplete, zsuggest, zcmd-result, zlog, zwhere, zd, zlock, zpublish.

zjob — bidirectional ptmx attach

zjob submit [--pty] [--cwd DIR] [--tag T...] [--env K=V...] -- CMD ARGS... zjob list [--state running|exited|killed|failed] [--tag T] [--limit N] zjob status <id> zjob output <id> [--follow] [--stderr] [--lines N] zjob attach <id> # read-only file-tail for non-pty; # bidirectional raw-mode pump for --pty zjob kill <id> [--signal NAME] zjob cancel <id> [--grace SECS] zjob wait <id> [--timeout SECS]

With --pty the daemon calls nix::pty::openpty() and the child runs with the slave on 0/1/2 via pre_exec dup2; the master fd lives in JobMeta. Two new IPC ops drive it:

  • job_input {id, bytes_b64} — base64-decode, write to master
  • job_resize {id, rows, cols}TIOCSWINSZ for SIGWINCH propagation

On zjob attach against a pty job: termios cfmakeraw on stdin, a stdin reader thread batches keystrokes and fires job_input, output is broadcast as job:N.stdout events with bytes_b64 payload (decoded back to the user's tty), and SIGWINCH is forwarded as job_resize. Ctrl-] is the detach key. Termios is restored on exit via a Drop guard. Use case: background jobs that block on stdin (deploy scripts asking y/n, REPLs in background) — submit with --pty, attach later, type, detach, attach again.

zsync up --all

Now wired (was a stub). The shell-side enumerator (src/extensions/overlay_snapshot.rs) snapshots every overlay table and ships push_canonical per subsystem. Covers alias/galias/salias, setopt, params (vars+arrays+assoc unioned), env, path, manpath, fpath, named_dir, compdef, zstyle. Skipped: function (needs source-text round-trip), bindkey (lives in ZleManager), zmodload (no canonical "currently loaded" list).

zsync up --all # promote every overlay subsystem zsync up <subsystem> KEY VALUE zsync up <subsystem> --json '<obj>' zsync pull <subsystem> zsync diff <subsystem> --overlay '<obj>' zsync watch <subsystem>...

[0x05] BYTECODE CACHING

Every autoload function in fpath gets compiled to fusevm bytecodes during compinit. Compiled chunks are serialized via rkyv into per-source-root shards and written by the daemon. Subsequent loads mmap the archive zero-copy, validate via bytecheck, and dispatch directly — no lex, no parse, no compile, no allocator hit.

First call to _git (daemon path): fpath/_git (source text) │ ▼ ShellParser::parse_script() ~1ms │ ▼ ShellCompiler::compile() ~0.5ms │ ▼ fusevm::Chunk (bytecodes) │ ├──► VM::run() native dispatch │ └──► rkyv::to_bytes() ~0.1ms (zero-copy archive) │ ▼ images/{hash}-fpath.rkyv (daemon writes) Every subsequent call (client path, ZERO daemon RTT): images/{hash}-fpath.rkyv mmap (kernel page cache) │ ▼ rkyv::access::<ArchivedChunk> ~0 µs (zero-copy access) │ ▼ fusevm::Chunk (no lexer, no parser, no compiler, no alloc) │ ▼ VM::run() native bytecode dispatch

[0x06] FUSEVM BYTECODE TARGET

100% lowered. Every shell construct compiles to fusevm bytecodes — a language-agnostic VM with fused superinstructions and Cranelift JIT. The same VM that powers stryke (which beats LuaJIT on benchmarks). No tree-walking interpreter remains. Hot bytecodes compile to native x86-64 machine code.

stryke source ───► stryke compiler ──┐ ├──► fusevm::Op ──► VM::run() ──► JIT ──► native zshrs source ───► shell compiler ──┘ │ ├── Linear JIT: straight-line code ├── Block JIT: loops, conditionals └── Cranelift codegen → x86-64

Shell constructs already lowered to fusevm bytecodes:

Arithmetic

$(( )) — full precedence, ternary, assignment, hex/octal, bitwise

Loops

for, for(()), while, until, repeat

Conditionals

if/elif/else, case, [[ ]] with all file tests and comparisons

Commands

Exec, ExecBg, pipelines, redirects, here-docs, here-strings

Functions

Definition, Call/Return, PushFrame/PopFrame

Fused Ops

AccumSumLoop, SlotIncLtIntJumpBack, PreIncSlotVoid — single-dispatch loop execution

[0x07] EXCLUSIVE BUILTINS

Parallel Primitives (VM-executed, zero fork)

BuiltinDescription
async / awaitShip work to pool, collect result
pmapParallel map with ordered output — compiles to bytecode, runs on VM, zero forks
pgrepParallel filter — compiles to bytecode, runs on VM, zero forks
peachParallel for-each, unordered — compiles to bytecode, runs on VM, zero forks
barrierRun all commands in parallel, wait for all

AOP / Debugging

BuiltinDescription
interceptAOP before/after/around advice on any command. Glob pattern matching. Nanosecond timing.
intercept_proceedCall original command from around advice.
doctorFull diagnostic: worker pool metrics, cache stats, bytecode coverage, startup health.
dbviewBrowse the daemon's catalog.db mirror without SQL. Tables: autoloads, comps, executables, history, plugins. Hot path uses rkyv mmap directly.
profileIn-process command profiling. Nanosecond accuracy. No fork overhead in measurement.

Unit Test Framework

Port of the strykelang test framework (stryke testzshrs --ztest). Worker-pool runner — one persistent --ztest-worker subprocess per CPU, fork-on-receive per test file, JSON-over-pipe wire protocol, per-test fd 2 capture so concurrent workers can’t tear each other’s lines. Test discovery: test_* / t_* prefix × .zsh/.sh/.zshrs suffix under t/ or tests/.

BuiltinDescription
zassert_eq / zassert_neString equality / inequality
zassert_ok / zassert_err / zassert_true / zassert_falseTruthiness (non-empty AND not "0" → truthy)
zassert_gt / zassert_lt / zassert_ge / zassert_leNumeric ordering
zassert_matchRegex match (Rust regex syntax)
zassert_containsSubstring containment
zassert_nearFloat approximate equality (epsilon)
zassert_diesPasses when given shell command exits non-zero
ztest_skipMark current assertion skipped (yellow ↓)
ztest_run / run_testsPrint summary, roll counters into totals
zshrs --ztest [-j N] [-q] [paths…]Worker-pool runner (default workers = num_cpus)
zshrs --ztest-workerPersistent worker subprocess (JSON over stdin/stdout)

Coreutils (Anti-Fork)

BuiltinDescriptionSpeedup vs fork
catConcatenate files — no fork2000-5000x
head / tailFirst/last N lines — no fork2000-5000x
wcLine/word/char count — no fork2000-5000x
sort / uniqSort and dedupe — no fork2000-5000x
findWalk directories — no fork2000-5000x
cut / tr / revText manipulation — no fork2000-5000x
seq / teeNumber sequences, copy stdin — no fork2000-5000x
dateCurrent date/time — direct strftime3000-8000x
sleepDelay — std::thread::sleep2000-5000x
mktempCreate temp file/dir — no fork2000-5000x
hostname / unameSystem info — direct syscall3000-8000x
id / whoamiUser info — direct syscall3000-8000x
touch / realpathFile ops — no fork2000-5000x
basename / dirnamePath manipulation — no fork2000-5000x
zgetattr / zsetattrxattr ops — direct syscall2000-5000x

[0x07b] SHELL LANGUAGE FEATURES

Every shell construct compiles to fusevm bytecode — no tree-walker dispatch lives in zshrs. The categories below are summaries; the full reference documents each entry with a runnable code example.

Control Flow

if, while, until, for, for ((;;)), case, select, coproc, break, continue, return, ;/&&/||/&.

Indexed Arrays

arr=(a b c), arr+=(d), ${arr[1]} (1-based), ${arr[-1]}, ${arr[@]} (argv splice), ${#arr[@]}.

Associative Arrays

typeset -A m, m[key]=val, ${m[key]}, ${(k)m} (keys), ${(v)m} (values).

Parameter Expansion

${var:-x}, ${var:=x}, ${var:?msg}, ${var:+x}, ${#var}, ${var:o:l}, ${var#pat}, ${var/pat/repl}, ${var:u}/:l.

Zsh Flags

(L)/(U) case, (j: :) join, (s. .) split, (f) newline-split, (o)/(O) sort, (P) indirect, (@) force-array, (k)/(v), (#). Stack: (jL), (s:,:U).

Redirects & Pipelines

> >> < <<EOF <<< 2>&1 &> &>> | |& ! <(cmd) >(cmd).

Background & Async

cmd & (fork + setsid), $!, wait, jobs/fg/bg; async/await (worker pool, no fork).

Coprocesses

coproc { body } creates two pipes, forks, registers $COPROC=[read_fd, write_fd]. Read from /dev/fd/${COPROC[1]}, write to /dev/fd/${COPROC[2]}.

Eval & Indirect Dispatch

eval 'echo $x' defers expansion correctly (single-quoted specials honored). cmd=ls; $cmd routes through host intercepts.

Arithmetic

$((expr)), (( cond )), let; full integer expression grammar compiled inline (no runtime parser).

Glob & Brace

*.rs, **/*.rs (parallel walk), {a,b,c}, {1..10}, glob qualifiers *(.x) *(N).

Tilde & Cmd-Sub

~, ~user, ~+/~-; $(cmd) (in-process pipe-capture), backticks.

For the complete catalog — every supported builtin, keyword, parameter-expansion form, ZshFlag, AOP primitive, parallel primitive, and anti-fork coreutils replacement with a code example for each — see the FULL REFERENCE.

[0x08] INSTALL

# Lean build — pure shell, all features, no stryke cargo install --path zsh # Fat build — shell + stryke runtime (@ prefix, AOP stryke advice) cargo install strykelang # From source git clone https://github.com/MenkeTechnologies/strykelang cd strykelang cargo build --release -p zsh # target/release/zshrs
# Set as default shell sudo sh -c 'echo /Users/$(whoami)/.cargo/bin/zshrs >> /etc/shells' chsh -s /Users/$(whoami)/.cargo/bin/zshrs # Tab completion for zshrs itself cp completions/_zshrs /usr/local/share/zsh/site-functions/

[0x09] DIAGNOSTICS

# Full health check zshrs --doctor # In-session diagnostics doctor # Browse cache dbview dbview autoloads _git # Profile a command profile 'compinit' profile -s 'for i in {1..1000}; do echo $i > /dev/null; done' # Show intercepts intercept list

[0x09b] ZSH CORPUS — LINE COUNTS & EXAMPLE SCRIPTS

Every *.zsh file shipped under this repo — parity corpus, recorder corpus, lexer corpus, demo scripts, the upstream src/zsh/Test harness, and the per-plugin test_corpus/. Counts and source bodies below are regenerated from the working tree by scripts/gen_zsh_corpus.py; never hand-edit.

1,487
.zsh files
136,448
total LOC
7
corpus groups
3,616
largest file (LOC)

Generated 2026-06-10 by scripts/gen_zsh_corpus.py. All counts derived live from find . -name '*.zsh'; never hand-edit numbers in this section.

Per-group totals

GroupFilesLOCShare
.claude88873,700 54.0%
examples37644,238 32.4%
tests/recorder_corpus3211,392 8.3%
test_corpus284,090 3.0%
tests/lexer_corpus331,881 1.4%
src/zsh2659 0.5%
tests/parity_corpus128488 0.4%
TOTAL1,487136,448100.0%

Top 10 by LOC

PathLOC
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/zinit/zinit-autoload.zsh3,616
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/zinit/zinit-autoload.zsh3,616
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/zinit/zinit-autoload.zsh3,616
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/zinit/zinit-autoload.zsh3,616
tests/recorder_corpus/zinit/zinit-autoload.zsh3,616
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/zinit/zinit.zsh3,351
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/zinit/zinit.zsh3,351
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/zinit/zinit.zsh3,351
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/zinit/zinit.zsh3,351
tests/recorder_corpus/zinit/zinit.zsh3,351

Full inventory

Full inventory — 1,487 files (click to expand)
PathLOC
.claude
.claude/worktrees/agent-a11a320a48a837c68/examples/daemon-shell.zsh574
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/alias-finder.plugin.zsh47
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/autojump.plugin.zsh36
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/branch.plugin.zsh35
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/dirhistory.plugin.zsh221
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/docker-aliases.zsh195
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/dotenv.plugin.zsh64
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/frontend-search.plugin.zsh112
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/git-lfs.plugin.zsh17
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/grc.zsh38
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/jhipster.plugin.zsh130
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/last-working-dir.plugin.zsh28
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/macos.plugin.zsh268
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/magic-enter.plugin.zsh38
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/man.plugin.zsh37
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/per-directory-history.zsh174
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/python.plugin.zsh83
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/svn.plugin.zsh89
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/systemd.plugin.zsh116
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/terraform.plugin.zsh17
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/thefuck.plugin.zsh21
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/xcode.plugin.zsh201
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/zpwr-syntax.zsh184
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/zpwr-verbs.zsh477
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/zpwr256ColorTest.zsh19
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/zsh-autocomplete.plugin.zsh35
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/zsh-cpan-completion.plugin.zsh79
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/zsh-z.plugin.zsh698
.claude/worktrees/agent-a11a320a48a837c68/test_corpus/ztst.zsh631
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/08_grc.zsh38
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/09_delete_dups.zsh21
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/10_zpwr-hash-dirs.zsh19
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/11_keybindings.zsh71
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/16_nested_cmdsubst.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/17_heredocs.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/18_param_expansion.zsh19
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/19_glob_qualifiers.zsh10
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/20_procsubst.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/21_dbrack_cond.zsh10
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/22_brace_expand.zsh7
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/23_arrays.zsh15
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/24_for_cstyle.zsh11
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/25_select_coproc_time.zsh16
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/26_quotes_mixed.zsh9
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/27_zinit_ice.zsh8
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/28_zsh_globs.zsh8
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/29_redirs_complex.zsh12
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/30_arith_complex.zsh13
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/31_nested_param_brack.zsh8
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/32_backticks_intick.zsh6
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/33_pattern_context.zsh9
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/34_typeset_options.zsh14
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/35_complex_quoting.zsh12
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/36_empty_paren.zsh14
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/37_continuation.zsh13
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/38_zsh_special_params.zsh18
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/39_omz_functions.zsh284
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/40_zinit_additional.zsh219
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/41_omz_git.zsh367
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/42_zinit_side.zsh397
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/43_zpwr_test_batch18.zsh209
.claude/worktrees/agent-a11a320a48a837c68/tests/lexer_corpus/44_lexer_niche.zsh13
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/01_simple_echo.zsh1
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/02_pipe_two.zsh1
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/03_assign_prefix.zsh1
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/04_andand.zsh1
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/05_subsh.zsh1
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/06_for_in.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/07_if_simple.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/08_funcdef.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/09_case_multi.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/100_glob_qualifiers.zsh13
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/101_case_select.zsh8
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/102_math_complex.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/103_param_complex.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/104_if_multi_elif.zsh10
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/105_case_complex.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/106_array_index.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/107_cond_not.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/108_time_block.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/109_if_multi_cond.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/10_cond_unary.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/110_while_multi_cond.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/111_case_empty.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/112_array_empty.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/113_param_double_colon.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/114_case_nested.zsh7
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/115_param_padding.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/116_proc_subst_eq.zsh1
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/117_time_pipeline.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/118_param_exp_multi.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/119_not_blocks.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/11_arith.zsh1
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/120_param_special.zsh8
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/121_math_ternary.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/122_case_multi_pat.zsh6
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/123_cond_misc.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/123_glob_qualifiers_more.zsh7
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/124_math_bitwise_complex.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/125_param_defined.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/126_func_shift.zsh6
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/127_redir_more.zsh8
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/128_math_ternary_complex.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/129_cmdsubst_nested.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/12_while.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/130_cond_logic.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/131_math_deep.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/132_pipe_multi.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/133_not_pipe_complex.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/134_brace_seq_step.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/135_cond_regex_complex.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/136_param_flags_final_v2.zsh7
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/137_param_modifiers.zsh11
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/138_math_ternary_nested.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/139_herestring_variations.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/13_redir_dup.zsh1
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/14_while.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/15_repeat.zsh1
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/16_try_always.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/17_cond_binary.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/21_select.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/22_arith_complex.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/23_param_expansion.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/25_coproc.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/26_time.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/27_case_terms.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/28_for_positional.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/29_nested_blocks.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/30_cond_complex.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/31_if_complex.zsh7
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/32_for_cstyle.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/33_redir_var.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/34_herestring.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/35_array_assign.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/36_brace_expand.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/37_proc_subst.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/41_nested_loops.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/45_herestring_complex.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/46_case_glob.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/47_func_keyword.zsh6
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/48_param_split_f.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/49_param_flags_basic.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/50_param_substring.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/51_param_subst.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/52_param_nested.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/53_param_cmdsubst.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/54_logical.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/55_negation.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/56_cond_file.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/57_cond_binary_files.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/58_cond_numeric.zsh6
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/59_case_patterns.zsh6
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/60_backticks.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/61_logical_complex.zsh1
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/62_param_length.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/63_param_default.zsh8
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/64_param_remove.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/65_alias.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/66_param_flags_advanced.zsh8
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/67_redir_force.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/68_multios.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/69_cmdsubst.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/70_param_pattern.zsh7
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/71_background.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/73_brace_basic.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/74_math_ops.zsh9
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/75_cond_file_more.zsh10
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/77_cmd_modifiers.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/78_param_flags_extra.zsh8
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/79_math_inc_dec.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/80_math_assign.zsh10
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/81_nested_complex.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/82_brace_seq.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/83_math_comma.zsh1
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/84_math_ops_more.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/85_cond_string_eq.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/86_empty_bodies.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/87_param_offset_negative.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/88_cond_regex_simple.zsh1
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/89_param_flags_count.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/90_param_flags_final.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/91_math_bitwise.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/92_nested_if.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/93_case_empty_arm.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/94_param_flags_D.zsh1
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/95_math_precedence.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/96_redir_fd_complex.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/97_expand_nesting_more.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/98_brace_comma_empty.zsh3
.claude/worktrees/agent-a11a320a48a837c68/tests/parity_corpus/99_param_flags_q_extra.zsh2
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/01_aliases_basic.zsh6
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/02_alias_redefine.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/03_alias_variants.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/04_exports.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/05_assigns.zsh5
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/06_setopts.zsh6
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/07_zstyle.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/08_bindkey.zsh6
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/09_hash_d.zsh6
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/10_traps.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/11_zmodload.zsh4
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/12_functions.zsh10
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/13_kitchen_sink.zsh15
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/14_conditional.zsh9
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/15_listing_only.zsh14
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/16_typeset_family.zsh11
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/17_autoload.zsh8
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/18_set_o_form.zsh8
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/19_unalias_unset.zsh13
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/20_function_forms.zsh27
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/21_assignment_forms.zsh35
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/22_zle_widgets.zsh14
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/23_completions_discover.zsh7
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/24_replay_types.zsh37
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/zinit/git-process-output.zsh186
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/zinit/zinit-additional.zsh219
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/zinit/zinit-autoload.zsh3,616
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/zinit/zinit-install.zsh2,451
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/zinit/zinit-side.zsh397
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/zinit/zinit.zsh3,351
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/zshrc/.zpwr/local/zpwr-hash-dirs.zsh19
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/zshrc/zshrc.zsh889
.claude/worktrees/agent-ab18cfe51348871be/examples/daemon-shell.zsh574
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/alias-finder.plugin.zsh47
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/autojump.plugin.zsh36
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/branch.plugin.zsh35
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/dirhistory.plugin.zsh221
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/docker-aliases.zsh195
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/dotenv.plugin.zsh64
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/frontend-search.plugin.zsh112
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/git-lfs.plugin.zsh17
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/grc.zsh38
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/jhipster.plugin.zsh130
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/last-working-dir.plugin.zsh28
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/macos.plugin.zsh268
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/magic-enter.plugin.zsh38
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/man.plugin.zsh37
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/per-directory-history.zsh174
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/python.plugin.zsh83
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/svn.plugin.zsh89
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/systemd.plugin.zsh116
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/terraform.plugin.zsh17
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/thefuck.plugin.zsh21
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/xcode.plugin.zsh201
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/zpwr-syntax.zsh184
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/zpwr-verbs.zsh477
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/zpwr256ColorTest.zsh19
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/zsh-autocomplete.plugin.zsh35
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/zsh-cpan-completion.plugin.zsh79
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/zsh-z.plugin.zsh698
.claude/worktrees/agent-ab18cfe51348871be/test_corpus/ztst.zsh631
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/08_grc.zsh38
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/09_delete_dups.zsh21
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/10_zpwr-hash-dirs.zsh19
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/11_keybindings.zsh71
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/16_nested_cmdsubst.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/17_heredocs.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/18_param_expansion.zsh19
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/19_glob_qualifiers.zsh10
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/20_procsubst.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/21_dbrack_cond.zsh10
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/22_brace_expand.zsh7
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/23_arrays.zsh15
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/24_for_cstyle.zsh11
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/25_select_coproc_time.zsh16
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/26_quotes_mixed.zsh9
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/27_zinit_ice.zsh8
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/28_zsh_globs.zsh8
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/29_redirs_complex.zsh12
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/30_arith_complex.zsh13
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/31_nested_param_brack.zsh8
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/32_backticks_intick.zsh6
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/33_pattern_context.zsh9
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/34_typeset_options.zsh14
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/35_complex_quoting.zsh12
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/36_empty_paren.zsh14
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/37_continuation.zsh13
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/38_zsh_special_params.zsh18
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/39_omz_functions.zsh284
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/40_zinit_additional.zsh219
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/41_omz_git.zsh367
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/42_zinit_side.zsh397
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/43_zpwr_test_batch18.zsh209
.claude/worktrees/agent-ab18cfe51348871be/tests/lexer_corpus/44_lexer_niche.zsh13
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/01_simple_echo.zsh1
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/02_pipe_two.zsh1
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/03_assign_prefix.zsh1
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/04_andand.zsh1
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/05_subsh.zsh1
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/06_for_in.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/07_if_simple.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/08_funcdef.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/09_case_multi.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/100_glob_qualifiers.zsh13
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/101_case_select.zsh8
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/102_math_complex.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/103_param_complex.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/104_if_multi_elif.zsh10
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/105_case_complex.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/106_array_index.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/107_cond_not.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/108_time_block.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/109_if_multi_cond.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/10_cond_unary.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/110_while_multi_cond.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/111_case_empty.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/112_array_empty.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/113_param_double_colon.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/114_case_nested.zsh7
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/115_param_padding.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/116_proc_subst_eq.zsh1
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/117_time_pipeline.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/118_param_exp_multi.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/119_not_blocks.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/11_arith.zsh1
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/120_param_special.zsh8
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/121_math_ternary.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/122_case_multi_pat.zsh6
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/123_cond_misc.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/123_glob_qualifiers_more.zsh7
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/124_math_bitwise_complex.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/125_param_defined.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/126_func_shift.zsh6
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/127_redir_more.zsh8
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/128_math_ternary_complex.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/129_cmdsubst_nested.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/12_while.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/130_cond_logic.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/131_math_deep.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/132_pipe_multi.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/133_not_pipe_complex.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/134_brace_seq_step.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/135_cond_regex_complex.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/136_param_flags_final_v2.zsh7
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/137_param_modifiers.zsh11
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/138_math_ternary_nested.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/139_herestring_variations.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/13_redir_dup.zsh1
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/14_while.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/15_repeat.zsh1
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/16_try_always.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/17_cond_binary.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/21_select.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/22_arith_complex.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/23_param_expansion.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/25_coproc.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/26_time.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/27_case_terms.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/28_for_positional.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/29_nested_blocks.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/30_cond_complex.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/31_if_complex.zsh7
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/32_for_cstyle.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/33_redir_var.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/34_herestring.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/35_array_assign.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/36_brace_expand.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/37_proc_subst.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/41_nested_loops.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/45_herestring_complex.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/46_case_glob.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/47_func_keyword.zsh6
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/48_param_split_f.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/49_param_flags_basic.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/50_param_substring.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/51_param_subst.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/52_param_nested.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/53_param_cmdsubst.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/54_logical.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/55_negation.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/56_cond_file.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/57_cond_binary_files.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/58_cond_numeric.zsh6
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/59_case_patterns.zsh6
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/60_backticks.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/61_logical_complex.zsh1
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/62_param_length.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/63_param_default.zsh8
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/64_param_remove.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/65_alias.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/66_param_flags_advanced.zsh8
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/67_redir_force.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/68_multios.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/69_cmdsubst.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/70_param_pattern.zsh7
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/71_background.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/73_brace_basic.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/74_math_ops.zsh9
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/75_cond_file_more.zsh10
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/77_cmd_modifiers.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/78_param_flags_extra.zsh8
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/79_math_inc_dec.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/80_math_assign.zsh10
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/81_nested_complex.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/82_brace_seq.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/83_math_comma.zsh1
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/84_math_ops_more.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/85_cond_string_eq.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/86_empty_bodies.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/87_param_offset_negative.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/88_cond_regex_simple.zsh1
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/89_param_flags_count.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/90_param_flags_final.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/91_math_bitwise.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/92_nested_if.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/93_case_empty_arm.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/94_param_flags_D.zsh1
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/95_math_precedence.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/96_redir_fd_complex.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/97_expand_nesting_more.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/98_brace_comma_empty.zsh3
.claude/worktrees/agent-ab18cfe51348871be/tests/parity_corpus/99_param_flags_q_extra.zsh2
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/01_aliases_basic.zsh6
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/02_alias_redefine.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/03_alias_variants.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/04_exports.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/05_assigns.zsh5
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/06_setopts.zsh6
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/07_zstyle.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/08_bindkey.zsh6
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/09_hash_d.zsh6
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/10_traps.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/11_zmodload.zsh4
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/12_functions.zsh10
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/13_kitchen_sink.zsh15
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/14_conditional.zsh9
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/15_listing_only.zsh14
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/16_typeset_family.zsh11
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/17_autoload.zsh8
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/18_set_o_form.zsh8
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/19_unalias_unset.zsh13
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/20_function_forms.zsh27
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/21_assignment_forms.zsh35
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/22_zle_widgets.zsh14
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/23_completions_discover.zsh7
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/24_replay_types.zsh37
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/zinit/git-process-output.zsh186
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/zinit/zinit-additional.zsh219
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/zinit/zinit-autoload.zsh3,616
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/zinit/zinit-install.zsh2,451
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/zinit/zinit-side.zsh397
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/zinit/zinit.zsh3,351
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/zshrc/.zpwr/local/zpwr-hash-dirs.zsh19
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/zshrc/zshrc.zsh889
.claude/worktrees/agent-abf1fcdc5c1253122/examples/daemon-shell.zsh574
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/alias-finder.plugin.zsh47
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/autojump.plugin.zsh36
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/branch.plugin.zsh35
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/dirhistory.plugin.zsh221
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/docker-aliases.zsh195
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/dotenv.plugin.zsh64
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/frontend-search.plugin.zsh112
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/git-lfs.plugin.zsh17
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/grc.zsh38
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/jhipster.plugin.zsh130
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/last-working-dir.plugin.zsh28
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/macos.plugin.zsh268
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/magic-enter.plugin.zsh38
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/man.plugin.zsh37
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/per-directory-history.zsh174
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/python.plugin.zsh83
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/svn.plugin.zsh89
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/systemd.plugin.zsh116
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/terraform.plugin.zsh17
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/thefuck.plugin.zsh21
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/xcode.plugin.zsh201
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/zpwr-syntax.zsh184
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/zpwr-verbs.zsh477
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/zpwr256ColorTest.zsh19
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/zsh-autocomplete.plugin.zsh35
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/zsh-cpan-completion.plugin.zsh79
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/zsh-z.plugin.zsh698
.claude/worktrees/agent-abf1fcdc5c1253122/test_corpus/ztst.zsh631
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/08_grc.zsh38
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/09_delete_dups.zsh21
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/10_zpwr-hash-dirs.zsh19
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/11_keybindings.zsh71
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/16_nested_cmdsubst.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/17_heredocs.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/18_param_expansion.zsh19
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/19_glob_qualifiers.zsh10
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/20_procsubst.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/21_dbrack_cond.zsh10
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/22_brace_expand.zsh7
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/23_arrays.zsh15
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/24_for_cstyle.zsh11
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/25_select_coproc_time.zsh16
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/26_quotes_mixed.zsh9
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/27_zinit_ice.zsh8
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/28_zsh_globs.zsh8
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/29_redirs_complex.zsh12
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/30_arith_complex.zsh13
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/31_nested_param_brack.zsh8
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/32_backticks_intick.zsh6
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/33_pattern_context.zsh9
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/34_typeset_options.zsh14
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/35_complex_quoting.zsh12
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/36_empty_paren.zsh14
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/37_continuation.zsh13
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/38_zsh_special_params.zsh18
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/39_omz_functions.zsh284
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/40_zinit_additional.zsh219
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/41_omz_git.zsh367
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/42_zinit_side.zsh397
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/43_zpwr_test_batch18.zsh209
.claude/worktrees/agent-abf1fcdc5c1253122/tests/lexer_corpus/44_lexer_niche.zsh13
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/01_simple_echo.zsh1
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/02_pipe_two.zsh1
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/03_assign_prefix.zsh1
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/04_andand.zsh1
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/05_subsh.zsh1
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/06_for_in.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/07_if_simple.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/08_funcdef.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/09_case_multi.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/100_glob_qualifiers.zsh13
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/101_case_select.zsh8
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/102_math_complex.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/103_param_complex.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/104_if_multi_elif.zsh10
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/105_case_complex.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/106_array_index.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/107_cond_not.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/108_time_block.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/109_if_multi_cond.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/10_cond_unary.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/110_while_multi_cond.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/111_case_empty.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/112_array_empty.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/113_param_double_colon.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/114_case_nested.zsh7
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/115_param_padding.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/116_proc_subst_eq.zsh1
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/117_time_pipeline.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/118_param_exp_multi.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/119_not_blocks.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/11_arith.zsh1
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/120_param_special.zsh8
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/121_math_ternary.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/122_case_multi_pat.zsh6
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/123_cond_misc.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/123_glob_qualifiers_more.zsh7
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/124_math_bitwise_complex.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/125_param_defined.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/126_func_shift.zsh6
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/127_redir_more.zsh8
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/128_math_ternary_complex.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/129_cmdsubst_nested.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/12_while.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/130_cond_logic.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/131_math_deep.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/132_pipe_multi.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/133_not_pipe_complex.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/134_brace_seq_step.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/135_cond_regex_complex.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/136_param_flags_final_v2.zsh7
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/137_param_modifiers.zsh11
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/138_math_ternary_nested.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/139_herestring_variations.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/13_redir_dup.zsh1
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/14_while.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/15_repeat.zsh1
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/16_try_always.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/17_cond_binary.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/21_select.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/22_arith_complex.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/23_param_expansion.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/25_coproc.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/26_time.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/27_case_terms.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/28_for_positional.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/29_nested_blocks.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/30_cond_complex.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/31_if_complex.zsh7
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/32_for_cstyle.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/33_redir_var.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/34_herestring.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/35_array_assign.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/36_brace_expand.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/37_proc_subst.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/41_nested_loops.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/45_herestring_complex.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/46_case_glob.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/47_func_keyword.zsh6
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/48_param_split_f.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/49_param_flags_basic.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/50_param_substring.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/51_param_subst.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/52_param_nested.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/53_param_cmdsubst.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/54_logical.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/55_negation.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/56_cond_file.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/57_cond_binary_files.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/58_cond_numeric.zsh6
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/59_case_patterns.zsh6
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/60_backticks.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/61_logical_complex.zsh1
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/62_param_length.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/63_param_default.zsh8
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/64_param_remove.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/65_alias.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/66_param_flags_advanced.zsh8
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/67_redir_force.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/68_multios.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/69_cmdsubst.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/70_param_pattern.zsh7
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/71_background.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/73_brace_basic.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/74_math_ops.zsh9
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/75_cond_file_more.zsh10
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/77_cmd_modifiers.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/78_param_flags_extra.zsh8
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/79_math_inc_dec.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/80_math_assign.zsh10
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/81_nested_complex.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/82_brace_seq.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/83_math_comma.zsh1
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/84_math_ops_more.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/85_cond_string_eq.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/86_empty_bodies.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/87_param_offset_negative.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/88_cond_regex_simple.zsh1
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/89_param_flags_count.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/90_param_flags_final.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/91_math_bitwise.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/92_nested_if.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/93_case_empty_arm.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/94_param_flags_D.zsh1
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/95_math_precedence.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/96_redir_fd_complex.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/97_expand_nesting_more.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/98_brace_comma_empty.zsh3
.claude/worktrees/agent-abf1fcdc5c1253122/tests/parity_corpus/99_param_flags_q_extra.zsh2
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/01_aliases_basic.zsh6
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/02_alias_redefine.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/03_alias_variants.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/04_exports.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/05_assigns.zsh5
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/06_setopts.zsh6
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/07_zstyle.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/08_bindkey.zsh6
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/09_hash_d.zsh6
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/10_traps.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/11_zmodload.zsh4
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/12_functions.zsh10
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/13_kitchen_sink.zsh15
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/14_conditional.zsh9
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/15_listing_only.zsh14
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/16_typeset_family.zsh11
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/17_autoload.zsh8
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/18_set_o_form.zsh8
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/19_unalias_unset.zsh13
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/20_function_forms.zsh27
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/21_assignment_forms.zsh35
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/22_zle_widgets.zsh14
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/23_completions_discover.zsh7
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/24_replay_types.zsh37
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/zinit/git-process-output.zsh186
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/zinit/zinit-additional.zsh219
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/zinit/zinit-autoload.zsh3,616
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/zinit/zinit-install.zsh2,451
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/zinit/zinit-side.zsh397
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/zinit/zinit.zsh3,351
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/zshrc/.zpwr/local/zpwr-hash-dirs.zsh19
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/zshrc/zshrc.zsh889
.claude/worktrees/agent-ae3722fc4bdbaa34b/examples/daemon-shell.zsh574
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/alias-finder.plugin.zsh47
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/autojump.plugin.zsh36
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/branch.plugin.zsh35
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/dirhistory.plugin.zsh221
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/docker-aliases.zsh195
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/dotenv.plugin.zsh64
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/frontend-search.plugin.zsh112
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/git-lfs.plugin.zsh17
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/grc.zsh38
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/jhipster.plugin.zsh130
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/last-working-dir.plugin.zsh28
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/macos.plugin.zsh268
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/magic-enter.plugin.zsh38
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/man.plugin.zsh37
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/per-directory-history.zsh174
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/python.plugin.zsh83
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/svn.plugin.zsh89
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/systemd.plugin.zsh116
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/terraform.plugin.zsh17
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/thefuck.plugin.zsh21
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/xcode.plugin.zsh201
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/zpwr-syntax.zsh184
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/zpwr-verbs.zsh477
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/zpwr256ColorTest.zsh19
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/zsh-autocomplete.plugin.zsh35
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/zsh-cpan-completion.plugin.zsh79
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/zsh-z.plugin.zsh698
.claude/worktrees/agent-ae3722fc4bdbaa34b/test_corpus/ztst.zsh631
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/08_grc.zsh38
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/09_delete_dups.zsh21
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/10_zpwr-hash-dirs.zsh19
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/11_keybindings.zsh71
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/16_nested_cmdsubst.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/17_heredocs.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/18_param_expansion.zsh19
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/19_glob_qualifiers.zsh10
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/20_procsubst.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/21_dbrack_cond.zsh10
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/22_brace_expand.zsh7
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/23_arrays.zsh15
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/24_for_cstyle.zsh11
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/25_select_coproc_time.zsh16
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/26_quotes_mixed.zsh9
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/27_zinit_ice.zsh8
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/28_zsh_globs.zsh8
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/29_redirs_complex.zsh12
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/30_arith_complex.zsh13
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/31_nested_param_brack.zsh8
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/32_backticks_intick.zsh6
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/33_pattern_context.zsh9
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/34_typeset_options.zsh14
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/35_complex_quoting.zsh12
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/36_empty_paren.zsh14
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/37_continuation.zsh13
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/38_zsh_special_params.zsh18
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/39_omz_functions.zsh284
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/40_zinit_additional.zsh219
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/41_omz_git.zsh367
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/42_zinit_side.zsh397
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/43_zpwr_test_batch18.zsh209
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/lexer_corpus/44_lexer_niche.zsh13
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/01_simple_echo.zsh1
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/02_pipe_two.zsh1
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/03_assign_prefix.zsh1
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/04_andand.zsh1
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/05_subsh.zsh1
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/06_for_in.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/07_if_simple.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/08_funcdef.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/09_case_multi.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/100_glob_qualifiers.zsh13
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/101_case_select.zsh8
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/102_math_complex.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/103_param_complex.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/104_if_multi_elif.zsh10
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/105_case_complex.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/106_array_index.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/107_cond_not.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/108_time_block.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/109_if_multi_cond.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/10_cond_unary.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/110_while_multi_cond.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/111_case_empty.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/112_array_empty.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/113_param_double_colon.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/114_case_nested.zsh7
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/115_param_padding.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/116_proc_subst_eq.zsh1
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/117_time_pipeline.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/118_param_exp_multi.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/119_not_blocks.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/11_arith.zsh1
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/120_param_special.zsh8
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/121_math_ternary.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/122_case_multi_pat.zsh6
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/123_cond_misc.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/123_glob_qualifiers_more.zsh7
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/124_math_bitwise_complex.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/125_param_defined.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/126_func_shift.zsh6
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/127_redir_more.zsh8
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/128_math_ternary_complex.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/129_cmdsubst_nested.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/12_while.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/130_cond_logic.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/131_math_deep.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/132_pipe_multi.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/133_not_pipe_complex.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/134_brace_seq_step.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/135_cond_regex_complex.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/136_param_flags_final_v2.zsh7
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/137_param_modifiers.zsh11
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/138_math_ternary_nested.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/139_herestring_variations.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/13_redir_dup.zsh1
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/14_while.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/15_repeat.zsh1
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/16_try_always.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/17_cond_binary.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/21_select.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/22_arith_complex.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/23_param_expansion.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/25_coproc.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/26_time.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/27_case_terms.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/28_for_positional.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/29_nested_blocks.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/30_cond_complex.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/31_if_complex.zsh7
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/32_for_cstyle.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/33_redir_var.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/34_herestring.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/35_array_assign.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/36_brace_expand.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/37_proc_subst.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/41_nested_loops.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/45_herestring_complex.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/46_case_glob.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/47_func_keyword.zsh6
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/48_param_split_f.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/49_param_flags_basic.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/50_param_substring.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/51_param_subst.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/52_param_nested.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/53_param_cmdsubst.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/54_logical.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/55_negation.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/56_cond_file.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/57_cond_binary_files.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/58_cond_numeric.zsh6
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/59_case_patterns.zsh6
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/60_backticks.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/61_logical_complex.zsh1
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/62_param_length.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/63_param_default.zsh8
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/64_param_remove.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/65_alias.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/66_param_flags_advanced.zsh8
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/67_redir_force.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/68_multios.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/69_cmdsubst.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/70_param_pattern.zsh7
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/71_background.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/73_brace_basic.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/74_math_ops.zsh9
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/75_cond_file_more.zsh10
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/77_cmd_modifiers.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/78_param_flags_extra.zsh8
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/79_math_inc_dec.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/80_math_assign.zsh10
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/81_nested_complex.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/82_brace_seq.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/83_math_comma.zsh1
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/84_math_ops_more.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/85_cond_string_eq.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/86_empty_bodies.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/87_param_offset_negative.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/88_cond_regex_simple.zsh1
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/89_param_flags_count.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/90_param_flags_final.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/91_math_bitwise.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/92_nested_if.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/93_case_empty_arm.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/94_param_flags_D.zsh1
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/95_math_precedence.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/96_redir_fd_complex.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/97_expand_nesting_more.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/98_brace_comma_empty.zsh3
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/parity_corpus/99_param_flags_q_extra.zsh2
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/01_aliases_basic.zsh6
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/02_alias_redefine.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/03_alias_variants.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/04_exports.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/05_assigns.zsh5
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/06_setopts.zsh6
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/07_zstyle.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/08_bindkey.zsh6
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/09_hash_d.zsh6
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/10_traps.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/11_zmodload.zsh4
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/12_functions.zsh10
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/13_kitchen_sink.zsh15
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/14_conditional.zsh9
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/15_listing_only.zsh14
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/16_typeset_family.zsh11
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/17_autoload.zsh8
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/18_set_o_form.zsh8
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/19_unalias_unset.zsh13
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/20_function_forms.zsh27
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/21_assignment_forms.zsh35
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/22_zle_widgets.zsh14
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/23_completions_discover.zsh7
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/24_replay_types.zsh37
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/zinit/git-process-output.zsh186
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/zinit/zinit-additional.zsh219
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/zinit/zinit-autoload.zsh3,616
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/zinit/zinit-install.zsh2,451
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/zinit/zinit-side.zsh397
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/zinit/zinit.zsh3,351
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/zshrc/.zpwr/local/zpwr-hash-dirs.zsh19
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/zshrc/zshrc.zsh889
examples
examples/daemon-shell.zsh575
examples/demos/01_hello.zsh13
examples/demos/02_arithmetic.zsh44
examples/demos/03_strings.zsh43
examples/demos/04_arrays.zsh44
examples/demos/05_assoc_arrays.zsh46
examples/demos/06_control_flow.zsh79
examples/demos/07_for_loops.zsh60
examples/demos/08_functions.zsh60
examples/demos/09_recursion.zsh57
examples/demos/100_zsh_features_summary.zsh94
examples/demos/101_subshell_grouping.zsh84
examples/demos/102_function_introspection.zsh74
examples/demos/103_exit_traps_advanced.zsh83
examples/demos/104_strict_arithmetic.zsh86
examples/demos/105_dispatch_table.zsh98
examples/demos/106_pipe_chains.zsh73
examples/demos/107_eval_metaprogramming.zsh91
examples/demos/108_globsubst_globalias.zsh81
examples/demos/109_arith_truth_tables.zsh94
examples/demos/10_fizzbuzz.zsh31
examples/demos/110_misc_advanced.zsh122
examples/demos/111_let_builtin.zsh82
examples/demos/112_assignment_forms.zsh92
examples/demos/113_tied_arrays.zsh54
examples/demos/114_local_modifiers.zsh105
examples/demos/115_param_strip_advanced.zsh76
examples/demos/116_cond_numeric_ops.zsh92
examples/demos/117_backref_replacement.zsh87
examples/demos/118_recursive_glob.zsh53
examples/demos/119_background_wait.zsh91
examples/demos/11_fibonacci.zsh52
examples/demos/120_utf8_strings.zsh87
examples/demos/121_mini_cat.zsh112
examples/demos/122_mini_grep.zsh102
examples/demos/123_mini_wc.zsh111
examples/demos/124_url_encode.zsh83
examples/demos/125_json_pretty.zsh85
examples/demos/126_xml_escape.zsh60
examples/demos/127_string_trim.zsh115
examples/demos/128_csv_writer.zsh66
examples/demos/129_assoc_serialize.zsh73
examples/demos/12_quicksort.zsh50
examples/demos/130_ini_parser.zsh112
examples/demos/131_emulate_modes.zsh82
examples/demos/132_ksh_patterns.zsh68
examples/demos/133_zstyle_demo.zsh68
examples/demos/134_compdef_signatures.zsh100
examples/demos/135_bindkey_config.zsh59
examples/demos/136_path_manipulation.zsh83
examples/demos/137_named_pipes.zsh43
examples/demos/138_lock_files.zsh119
examples/demos/139_env_manipulation.zsh74
examples/demos/13_prime_sieve.zsh49
examples/demos/140_signal_handling.zsh90
examples/demos/141_color_codes.zsh74
examples/demos/142_calc_engine.zsh110
examples/demos/143_todo_app.zsh115
examples/demos/144_graph_bfs.zsh136
examples/demos/145_state_machine.zsh66
examples/demos/146_topological_sort.zsh108
examples/demos/147_pomodoro_timer.zsh65
examples/demos/148_inventory_system.zsh100
examples/demos/149_event_log.zsh92
examples/demos/14_brace_expansion.zsh43
examples/demos/150_lru_cache.zsh108
examples/demos/151_priority_queue.zsh49
examples/demos/152_bloom_filter.zsh82
examples/demos/153_trie.zsh88
examples/demos/154_levenshtein.zsh76
examples/demos/155_text_diff.zsh75
examples/demos/156_simple_template.zsh77
examples/demos/157_observer_pattern.zsh101
examples/demos/158_simulate_random.zsh79
examples/demos/159_bank_account.zsh105
examples/demos/15_parameter_expansion.zsh54
examples/demos/160_zshrs_capabilities.zsh87
examples/demos/161_dirstack.zsh70
examples/demos/162_umask_ulimit.zsh89
examples/demos/163_quoting_flags.zsh81
examples/demos/164_z_split_shell.zsh73
examples/demos/165_print_advanced.zsh75
examples/demos/166_glob_flags.zsh86
examples/demos/167_mini_find.zsh108
examples/demos/168_mini_make.zsh79
examples/demos/169_markdown_to_text.zsh76
examples/demos/16_parameter_flags.zsh47
examples/demos/170_regex_tester.zsh73
examples/demos/171_moving_average.zsh80
examples/demos/172_password_check.zsh91
examples/demos/173_anagram_finder.zsh80
examples/demos/174_number_to_words.zsh93
examples/demos/175_ascii_chart.zsh107
examples/demos/176_game_of_life.zsh109
examples/demos/177_days_between.zsh117
examples/demos/178_maze_generator.zsh100
examples/demos/179_lottery_sim.zsh83
examples/demos/17_heredocs.zsh69
examples/demos/180_calendar.zsh105
examples/demos/181_fizzbuzz_variants.zsh84
examples/demos/182_progress_bar.zsh56
examples/demos/183_word_frequency.zsh64
examples/demos/184_simple_cron.zsh80
examples/demos/185_final_recap.zsh76
examples/demos/186_alias_forms.zsh89
examples/demos/187_hex_dump.zsh80
examples/demos/188_ip_parser.zsh111
examples/demos/189_http_status.zsh86
examples/demos/18_cmd_substitution.zsh47
examples/demos/190_ansi_stripper.zsh72
examples/demos/191_retry_backoff.zsh86
examples/demos/192_memoize.zsh100
examples/demos/193_log_rotate.zsh72
examples/demos/194_url_parser.zsh115
examples/demos/195_sha_simple_hash.zsh110
examples/demos/196_base64.zsh94
examples/demos/197_csv_full_parse.zsh76
examples/demos/198_yaml_lite.zsh79
examples/demos/199_color_picker.zsh61
examples/demos/19_pipes_and_filters.zsh38
examples/demos/200_milestone.zsh72
examples/demos/201_unit_converter.zsh127
examples/demos/202_tokenizer.zsh100
examples/demos/203_argv_dispatch.zsh139
examples/demos/204_string_interpolation.zsh89
examples/demos/205_zsh_in_scripts.zsh94
examples/demos/206_assoc_iteration.zsh107
examples/demos/207_lru_with_ttl.zsh95
examples/demos/208_directory_walker.zsh109
examples/demos/209_command_pipeline.zsh97
examples/demos/20_process_substitution.zsh26
examples/demos/210_quine.zsh77
examples/demos/211_csv_to_md.zsh60
examples/demos/212_markdown_table.zsh94
examples/demos/213_ssh_config_parser.zsh88
examples/demos/214_chess_board.zsh77
examples/demos/215_tic_tac_toe.zsh106
examples/demos/216_deck_of_cards.zsh111
examples/demos/217_guess_number.zsh110
examples/demos/218_quiz_game.zsh65
examples/demos/219_madlibs.zsh80
examples/demos/21_printf_demo.zsh41
examples/demos/220_expense_tracker.zsh104
examples/demos/221_zsh_xtrace.zsh83
examples/demos/222_zsh_psvars.zsh91
examples/demos/223_funcstack.zsh93
examples/demos/224_git_log_parser.zsh135
examples/demos/225_nginx_log_analyze.zsh69
examples/demos/226_todo_categories.zsh119
examples/demos/227_hashtable_oa.zsh126
examples/demos/228_stack_machine.zsh131
examples/demos/229_search_filter.zsh120
examples/demos/22_trap_exit.zsh28
examples/demos/230_menu_system.zsh105
examples/demos/231_text_adventure.zsh117
examples/demos/232_time_tracker.zsh88
examples/demos/233_word_chain.zsh72
examples/demos/234_simple_kvs.zsh110
examples/demos/235_grand_finale.zsh96
examples/demos/236_zsh_hooks.zsh91
examples/demos/237_zsh_autoload.zsh106
examples/demos/238_dijkstra.zsh126
examples/demos/239_sudoku_validate.zsh223
examples/demos/23_ifs_split.zsh41
examples/demos/240_lights_out.zsh130
examples/demos/241_hangman.zsh126
examples/demos/242_number_sequences.zsh153
examples/demos/243_sierpinski.zsh85
examples/demos/244_mandelbrot_ascii.zsh124
examples/demos/245_toml_parser.zsh117
examples/demos/246_env_file_parser.zsh109
examples/demos/247_shebang_detector.zsh142
examples/demos/248_charset_validator.zsh133
examples/demos/249_whitespace_normalizer.zsh137
examples/demos/24_word_count.zsh40
examples/demos/250_shopping_cart.zsh173
examples/demos/251_vigenere_cipher.zsh122
examples/demos/252_caesar_cipher.zsh88
examples/demos/253_word_search.zsh101
examples/demos/254_ascii_clock.zsh135
examples/demos/255_ipv6_parser.zsh196
examples/demos/256_recipe_converter.zsh164
examples/demos/257_memory_match.zsh141
examples/demos/258_substitution_cipher.zsh150
examples/demos/259_boggle_solver.zsh124
examples/demos/25_reverse_string.zsh43
examples/demos/260_final_v3.zsh123
examples/demos/261_prime_factorize.zsh92
examples/demos/262_miller_rabin.zsh119
examples/demos/263_extended_gcd.zsh112
examples/demos/264_a_star_pathfind.zsh152
examples/demos/265_kruskal_mst.zsh139
examples/demos/266_prim_mst.zsh104
examples/demos/267_floyd_warshall.zsh151
examples/demos/268_bellman_ford.zsh149
examples/demos/269_n_queens.zsh108
examples/demos/26_anonymous_fn.zsh48
examples/demos/270_fifteen_puzzle.zsh142
examples/demos/271_hanoi_animated.zsh138
examples/demos/272_markdown_to_html.zsh201
examples/demos/273_http_parser.zsh167
examples/demos/274_log_format_detect.zsh141
examples/demos/275_csv_merge.zsh145
examples/demos/276_blackjack.zsh188
examples/demos/277_dice_game.zsh161
examples/demos/278_rps.zsh146
examples/demos/279_xor_cipher.zsh157
examples/demos/27_positional_args.zsh44
examples/demos/280_otp_pad.zsh162
examples/demos/281_zsh_periodic.zsh120
examples/demos/282_zsh_argv_special.zsh169
examples/demos/283_zsh_traps_full.zsh145
examples/demos/284_atomic_write.zsh143
examples/demos/285_banner_v4.zsh129
examples/demos/286_segment_tree.zsh147
examples/demos/287_fenwick_tree.zsh161
examples/demos/288_kmp_match.zsh168
examples/demos/289_rabin_karp.zsh132
examples/demos/28_typeset.zsh50
examples/demos/290_manacher.zsh205
examples/demos/291_reservoir_sample.zsh163
examples/demos/292_skiplist.zsh184
examples/demos/293_suffix_array.zsh176
examples/demos/294_word_ladder.zsh165
examples/demos/295_soundex.zsh164
examples/demos/296_minesweeper.zsh208
examples/demos/297_mastermind.zsh147
examples/demos/298_ttt_minimax.zsh213
examples/demos/299_conway_animated.zsh176
examples/demos/29_matrix_print.zsh56
examples/demos/300_milestone_300.zsh118
examples/demos/301_url_template.zsh178
examples/demos/302_sql_mini_parser.zsh220
examples/demos/303_zsh_print_z.zsh110
examples/demos/304_zsh_unhash_pattern.zsh149
examples/demos/305_zsh_typeset_m.zsh151
examples/demos/306_zsh_zle_widgets.zsh143
examples/demos/307_zsh_compsys_args.zsh143
examples/demos/308_kruskal_algo_density.zsh193
examples/demos/309_state_machine_dsl.zsh165
examples/demos/30_pattern_match.zsh84
examples/demos/310_banner_v5.zsh133
examples/demos/311_bst.zsh205
examples/demos/312_avl_tree.zsh195
examples/demos/313_bloom_filter_v2.zsh182
examples/demos/314_deque.zsh179
examples/demos/315_ring_buffer.zsh178
examples/demos/316_ipv4_subnet.zsh189
examples/demos/317_mac_address.zsh193
examples/demos/318_file_checksum.zsh149
examples/demos/319_anagram_solver.zsh169
examples/demos/31_stack.zsh39
examples/demos/320_leet_speak.zsh169
examples/demos/321_pig_latin.zsh171
examples/demos/322_history_parser.zsh176
examples/demos/323_ssh_known_hosts.zsh162
examples/demos/324_brace_advanced.zsh131
examples/demos/325_zsh_print_more.zsh135
examples/demos/326_zsh_compinit.zsh148
examples/demos/327_zsh_extended_glob.zsh178
examples/demos/328_zsh_kv_assoc.zsh189
examples/demos/329_max_subarray.zsh224
examples/demos/32_queue.zsh47
examples/demos/330_lis_lcs.zsh231
examples/demos/331_knapsack.zsh179
examples/demos/332_coin_change.zsh179
examples/demos/333_topological_sort.zsh242
examples/demos/334_lru_cache.zsh198
examples/demos/335_banner_v6.zsh130
examples/demos/336_roman_numeral.zsh163
examples/demos/337_trie_advanced.zsh204
examples/demos/338_z_function.zsh161
examples/demos/339_longest_common_substring.zsh169
examples/demos/33_binary_search.zsh38
examples/demos/340_palindromic_subseq.zsh234
examples/demos/341_nim_game.zsh228
examples/demos/342_peg_solitaire.zsh220
examples/demos/343_rfc2822_date.zsh217
examples/demos/344_iso8601.zsh256
examples/demos/345_pollard_rho.zsh181
examples/demos/346_continued_fraction.zsh162
examples/demos/347_transposition_cipher.zsh235
examples/demos/348_color_conversions.zsh255
examples/demos/349_zsh_eval_context.zsh187
examples/demos/34_bubble_sort.zsh37
examples/demos/350_milestone_350.zsh117
examples/demos/351_sokoban_small.zsh222
examples/demos/352_text_wrap.zsh220
examples/demos/353_unicode_utils.zsh231
examples/demos/354_url_encode.zsh269
examples/demos/355_calendar_print.zsh209
examples/demos/356_disjoint_set.zsh261
examples/demos/357_priority_queue.zsh297
examples/demos/358_zsh_funcfile.zsh207
examples/demos/359_zsh_param_complete.zsh198
examples/demos/35_insertion_sort.zsh36
examples/demos/360_banner_v7.zsh114
examples/demos/361_json_parser_full.zsh714
examples/demos/362_xml_parser_full.zsh632
examples/demos/363_arith_expr_evaluator.zsh703
examples/demos/364_csv_rfc4180.zsh559
examples/demos/365_mini_lisp.zsh699
examples/demos/366_sudoku_solver_bt.zsh383
examples/demos/367_banner_v8.zsh126
examples/demos/368_bencode_roundtrip.zsh183
examples/demos/369_hamming_7_4.zsh88
examples/demos/36_selection_sort.zsh39
examples/demos/370_skyline.zsh162
examples/demos/371_brainfuck_interp.zsh107
examples/demos/372_ackermann.zsh94
examples/demos/373_lzw_codec.zsh158
examples/demos/374_elias_gamma.zsh151
examples/demos/375_banner_v9.zsh98
examples/demos/37_counting_sort.zsh40
examples/demos/38_set_ops.zsh54
examples/demos/39_matrix_multiply.zsh53
examples/demos/40_roman_numerals.zsh66
examples/demos/41_base_convert.zsh60
examples/demos/42_tower_of_hanoi.zsh39
examples/demos/43_collatz.zsh61
examples/demos/44_happy_numbers.zsh69
examples/demos/45_armstrong.zsh46
examples/demos/46_perfect_numbers.zsh54
examples/demos/47_rot13.zsh29
examples/demos/48_atbash.zsh31
examples/demos/49_word_reverse.zsh49
examples/demos/50_histogram.zsh58
examples/demos/51_csv_parse.zsh61
examples/demos/52_env_basics.zsh51
examples/demos/53_file_tests.zsh63
examples/demos/54_date_format.zsh49
examples/demos/55_read_loop.zsh62
examples/demos/56_exit_codes.zsh55
examples/demos/57_atoi_itoa.zsh59
examples/demos/58_gcd_lcm.zsh72
examples/demos/59_string_reverse_ops.zsh84
examples/demos/60_mapfile_like.zsh52
examples/demos/61_zsh_modifiers.zsh46
examples/demos/62_param_flags_match.zsh56
examples/demos/63_param_flags_join_split.zsh53
examples/demos/64_param_flags_case.zsh52
examples/demos/65_param_flags_sort.zsh57
examples/demos/66_param_flags_format.zsh51
examples/demos/67_glob_qualifiers.zsh69
examples/demos/68_extended_glob.zsh77
examples/demos/69_assoc_advanced.zsh90
examples/demos/70_array_set_ops_zsh.zsh75
examples/demos/71_array_pattern_filter.zsh72
examples/demos/72_typeset_int_base.zsh62
examples/demos/73_print_columnar.zsh57
examples/demos/74_print_prompt_escapes.zsh54
examples/demos/75_zparseopts.zsh80
examples/demos/76_mathfunc.zsh68
examples/demos/77_datetime.zsh63
examples/demos/78_setopt_local_scope.zsh81
examples/demos/79_eval_dynamic_dispatch.zsh79
examples/demos/80_anon_fn_args.zsh88
examples/demos/81_compound_defaults.zsh83
examples/demos/82_brace_advanced.zsh78
examples/demos/83_history_modifiers.zsh79
examples/demos/84_subst_split_complex.zsh87
examples/demos/85_zcalc_repl.zsh99
examples/demos/86_setopt_exhaustive.zsh80
examples/demos/87_read_advanced.zsh55
examples/demos/88_printf_format_advanced.zsh77
examples/demos/89_regex_match.zsh67
examples/demos/90_type_whence.zsh75
examples/demos/91_hash_builtin.zsh68
examples/demos/92_arithmetic_for.zsh98
examples/demos/93_nested_assoc.zsh100
examples/demos/94_case_advanced.zsh91
examples/demos/95_fd_redirection.zsh79
examples/demos/96_strict_mode.zsh82
examples/demos/97_indirection.zsh112
examples/demos/98_coreutils_builtins.zsh82
examples/demos/99_negative_indexing.zsh76
src/zsh
src/zsh/Test/runtests.zsh28
src/zsh/Test/ztst.zsh631
test_corpus
test_corpus/alias-finder.plugin.zsh47
test_corpus/autojump.plugin.zsh36
test_corpus/branch.plugin.zsh35
test_corpus/dirhistory.plugin.zsh221
test_corpus/docker-aliases.zsh195
test_corpus/dotenv.plugin.zsh64
test_corpus/frontend-search.plugin.zsh112
test_corpus/git-lfs.plugin.zsh17
test_corpus/grc.zsh38
test_corpus/jhipster.plugin.zsh130
test_corpus/last-working-dir.plugin.zsh28
test_corpus/macos.plugin.zsh268
test_corpus/magic-enter.plugin.zsh38
test_corpus/man.plugin.zsh37
test_corpus/per-directory-history.zsh174
test_corpus/python.plugin.zsh83
test_corpus/svn.plugin.zsh89
test_corpus/systemd.plugin.zsh116
test_corpus/terraform.plugin.zsh17
test_corpus/thefuck.plugin.zsh21
test_corpus/xcode.plugin.zsh201
test_corpus/zpwr-syntax.zsh184
test_corpus/zpwr-verbs.zsh477
test_corpus/zpwr256ColorTest.zsh19
test_corpus/zsh-autocomplete.plugin.zsh35
test_corpus/zsh-cpan-completion.plugin.zsh79
test_corpus/zsh-z.plugin.zsh698
test_corpus/ztst.zsh631
tests/lexer_corpus
tests/lexer_corpus/08_grc.zsh38
tests/lexer_corpus/09_delete_dups.zsh21
tests/lexer_corpus/10_zpwr-hash-dirs.zsh19
tests/lexer_corpus/11_keybindings.zsh71
tests/lexer_corpus/16_nested_cmdsubst.zsh4
tests/lexer_corpus/17_heredocs.zsh3
tests/lexer_corpus/18_param_expansion.zsh19
tests/lexer_corpus/19_glob_qualifiers.zsh10
tests/lexer_corpus/20_procsubst.zsh4
tests/lexer_corpus/21_dbrack_cond.zsh10
tests/lexer_corpus/22_brace_expand.zsh7
tests/lexer_corpus/23_arrays.zsh15
tests/lexer_corpus/24_for_cstyle.zsh11
tests/lexer_corpus/25_select_coproc_time.zsh16
tests/lexer_corpus/26_quotes_mixed.zsh9
tests/lexer_corpus/27_zinit_ice.zsh8
tests/lexer_corpus/28_zsh_globs.zsh8
tests/lexer_corpus/29_redirs_complex.zsh12
tests/lexer_corpus/30_arith_complex.zsh13
tests/lexer_corpus/31_nested_param_brack.zsh8
tests/lexer_corpus/32_backticks_intick.zsh6
tests/lexer_corpus/33_pattern_context.zsh9
tests/lexer_corpus/34_typeset_options.zsh14
tests/lexer_corpus/35_complex_quoting.zsh12
tests/lexer_corpus/36_empty_paren.zsh14
tests/lexer_corpus/37_continuation.zsh13
tests/lexer_corpus/38_zsh_special_params.zsh18
tests/lexer_corpus/39_omz_functions.zsh284
tests/lexer_corpus/40_zinit_additional.zsh219
tests/lexer_corpus/41_omz_git.zsh367
tests/lexer_corpus/42_zinit_side.zsh397
tests/lexer_corpus/43_zpwr_test_batch18.zsh209
tests/lexer_corpus/44_lexer_niche.zsh13
tests/parity_corpus
tests/parity_corpus/01_simple_echo.zsh1
tests/parity_corpus/02_pipe_two.zsh1
tests/parity_corpus/03_assign_prefix.zsh1
tests/parity_corpus/04_andand.zsh1
tests/parity_corpus/05_subsh.zsh1
tests/parity_corpus/06_for_in.zsh3
tests/parity_corpus/07_if_simple.zsh3
tests/parity_corpus/08_funcdef.zsh3
tests/parity_corpus/09_case_multi.zsh4
tests/parity_corpus/100_glob_qualifiers.zsh13
tests/parity_corpus/101_case_select.zsh8
tests/parity_corpus/102_math_complex.zsh4
tests/parity_corpus/103_param_complex.zsh4
tests/parity_corpus/104_if_multi_elif.zsh10
tests/parity_corpus/105_case_complex.zsh5
tests/parity_corpus/106_array_index.zsh5
tests/parity_corpus/107_cond_not.zsh3
tests/parity_corpus/108_time_block.zsh3
tests/parity_corpus/109_if_multi_cond.zsh4
tests/parity_corpus/10_cond_unary.zsh3
tests/parity_corpus/110_while_multi_cond.zsh4
tests/parity_corpus/111_case_empty.zsh2
tests/parity_corpus/112_array_empty.zsh2
tests/parity_corpus/113_param_double_colon.zsh4
tests/parity_corpus/114_case_nested.zsh7
tests/parity_corpus/115_param_padding.zsh3
tests/parity_corpus/116_proc_subst_eq.zsh1
tests/parity_corpus/117_time_pipeline.zsh2
tests/parity_corpus/118_param_exp_multi.zsh4
tests/parity_corpus/119_not_blocks.zsh3
tests/parity_corpus/11_arith.zsh1
tests/parity_corpus/120_param_special.zsh8
tests/parity_corpus/121_math_ternary.zsh2
tests/parity_corpus/122_case_multi_pat.zsh6
tests/parity_corpus/123_cond_misc.zsh4
tests/parity_corpus/123_glob_qualifiers_more.zsh7
tests/parity_corpus/124_math_bitwise_complex.zsh3
tests/parity_corpus/125_param_defined.zsh5
tests/parity_corpus/126_func_shift.zsh6
tests/parity_corpus/127_redir_more.zsh8
tests/parity_corpus/128_math_ternary_complex.zsh2
tests/parity_corpus/129_cmdsubst_nested.zsh3
tests/parity_corpus/12_while.zsh4
tests/parity_corpus/130_cond_logic.zsh3
tests/parity_corpus/131_math_deep.zsh2
tests/parity_corpus/132_pipe_multi.zsh2
tests/parity_corpus/133_not_pipe_complex.zsh3
tests/parity_corpus/134_brace_seq_step.zsh4
tests/parity_corpus/135_cond_regex_complex.zsh2
tests/parity_corpus/136_param_flags_final_v2.zsh7
tests/parity_corpus/137_param_modifiers.zsh11
tests/parity_corpus/138_math_ternary_nested.zsh3
tests/parity_corpus/139_herestring_variations.zsh4
tests/parity_corpus/13_redir_dup.zsh1
tests/parity_corpus/14_while.zsh5
tests/parity_corpus/15_repeat.zsh1
tests/parity_corpus/16_try_always.zsh5
tests/parity_corpus/17_cond_binary.zsh3
tests/parity_corpus/21_select.zsh4
tests/parity_corpus/22_arith_complex.zsh3
tests/parity_corpus/23_param_expansion.zsh4
tests/parity_corpus/25_coproc.zsh2
tests/parity_corpus/26_time.zsh2
tests/parity_corpus/27_case_terms.zsh5
tests/parity_corpus/28_for_positional.zsh3
tests/parity_corpus/29_nested_blocks.zsh2
tests/parity_corpus/30_cond_complex.zsh3
tests/parity_corpus/31_if_complex.zsh7
tests/parity_corpus/32_for_cstyle.zsh3
tests/parity_corpus/33_redir_var.zsh3
tests/parity_corpus/34_herestring.zsh2
tests/parity_corpus/35_array_assign.zsh4
tests/parity_corpus/36_brace_expand.zsh3
tests/parity_corpus/37_proc_subst.zsh2
tests/parity_corpus/41_nested_loops.zsh5
tests/parity_corpus/45_herestring_complex.zsh2
tests/parity_corpus/46_case_glob.zsh5
tests/parity_corpus/47_func_keyword.zsh6
tests/parity_corpus/48_param_split_f.zsh4
tests/parity_corpus/49_param_flags_basic.zsh3
tests/parity_corpus/50_param_substring.zsh2
tests/parity_corpus/51_param_subst.zsh4
tests/parity_corpus/52_param_nested.zsh3
tests/parity_corpus/53_param_cmdsubst.zsh2
tests/parity_corpus/54_logical.zsh2
tests/parity_corpus/55_negation.zsh3
tests/parity_corpus/56_cond_file.zsh5
tests/parity_corpus/57_cond_binary_files.zsh3
tests/parity_corpus/58_cond_numeric.zsh6
tests/parity_corpus/59_case_patterns.zsh6
tests/parity_corpus/60_backticks.zsh2
tests/parity_corpus/61_logical_complex.zsh1
tests/parity_corpus/62_param_length.zsh3
tests/parity_corpus/63_param_default.zsh8
tests/parity_corpus/64_param_remove.zsh4
tests/parity_corpus/65_alias.zsh2
tests/parity_corpus/66_param_flags_advanced.zsh8
tests/parity_corpus/67_redir_force.zsh5
tests/parity_corpus/68_multios.zsh3
tests/parity_corpus/69_cmdsubst.zsh4
tests/parity_corpus/70_param_pattern.zsh7
tests/parity_corpus/71_background.zsh3
tests/parity_corpus/73_brace_basic.zsh3
tests/parity_corpus/74_math_ops.zsh9
tests/parity_corpus/75_cond_file_more.zsh10
tests/parity_corpus/77_cmd_modifiers.zsh3
tests/parity_corpus/78_param_flags_extra.zsh8
tests/parity_corpus/79_math_inc_dec.zsh4
tests/parity_corpus/80_math_assign.zsh10
tests/parity_corpus/81_nested_complex.zsh3
tests/parity_corpus/82_brace_seq.zsh2
tests/parity_corpus/83_math_comma.zsh1
tests/parity_corpus/84_math_ops_more.zsh2
tests/parity_corpus/85_cond_string_eq.zsh3
tests/parity_corpus/86_empty_bodies.zsh2
tests/parity_corpus/87_param_offset_negative.zsh2
tests/parity_corpus/88_cond_regex_simple.zsh1
tests/parity_corpus/89_param_flags_count.zsh2
tests/parity_corpus/90_param_flags_final.zsh5
tests/parity_corpus/91_math_bitwise.zsh4
tests/parity_corpus/92_nested_if.zsh5
tests/parity_corpus/93_case_empty_arm.zsh4
tests/parity_corpus/94_param_flags_D.zsh1
tests/parity_corpus/95_math_precedence.zsh2
tests/parity_corpus/96_redir_fd_complex.zsh4
tests/parity_corpus/97_expand_nesting_more.zsh3
tests/parity_corpus/98_brace_comma_empty.zsh3
tests/parity_corpus/99_param_flags_q_extra.zsh2
tests/recorder_corpus
tests/recorder_corpus/01_aliases_basic.zsh6
tests/recorder_corpus/02_alias_redefine.zsh5
tests/recorder_corpus/03_alias_variants.zsh5
tests/recorder_corpus/04_exports.zsh5
tests/recorder_corpus/05_assigns.zsh5
tests/recorder_corpus/06_setopts.zsh6
tests/recorder_corpus/07_zstyle.zsh4
tests/recorder_corpus/08_bindkey.zsh6
tests/recorder_corpus/09_hash_d.zsh6
tests/recorder_corpus/10_traps.zsh4
tests/recorder_corpus/11_zmodload.zsh4
tests/recorder_corpus/12_functions.zsh10
tests/recorder_corpus/13_kitchen_sink.zsh15
tests/recorder_corpus/14_conditional.zsh9
tests/recorder_corpus/15_listing_only.zsh14
tests/recorder_corpus/16_typeset_family.zsh11
tests/recorder_corpus/17_autoload.zsh8
tests/recorder_corpus/18_set_o_form.zsh8
tests/recorder_corpus/19_unalias_unset.zsh13
tests/recorder_corpus/20_function_forms.zsh27
tests/recorder_corpus/21_assignment_forms.zsh35
tests/recorder_corpus/22_zle_widgets.zsh14
tests/recorder_corpus/23_completions_discover.zsh7
tests/recorder_corpus/24_replay_types.zsh37
tests/recorder_corpus/zinit/git-process-output.zsh186
tests/recorder_corpus/zinit/zinit-additional.zsh219
tests/recorder_corpus/zinit/zinit-autoload.zsh3,616
tests/recorder_corpus/zinit/zinit-install.zsh2,451
tests/recorder_corpus/zinit/zinit-side.zsh397
tests/recorder_corpus/zinit/zinit.zsh3,351
tests/recorder_corpus/zshrc/.zpwr/local/zpwr-hash-dirs.zsh19
tests/recorder_corpus/zshrc/zshrc.zsh889

Embedded example scripts (top 10 by LOC)

Full source of the largest corpus scripts. Each is collapsed by default; sources beyond 800 lines are truncated with a count of trailing lines.

.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/zinit/zinit-autoload.zsh — 3,616 LOC
#!/usr/bin/env zsh
#
# zdharma-continuum/zinit/zinit-autoload.zsh
# Copyright (c) 2016-2021 Sebastian Gniazdowski
# Copyright (c) 2021-2023 zdharma-continuum
# Homepage: https://github.com/zdharma-continuum/zinit
# License: MIT License
#

builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { builtin print -P "${ZINIT[col-error]}ERROR:%f%b Couldn't find ${ZINIT[col-obj]}zinit-side.zsh%f%b."; return 1; }

ZINIT[EXTENDED_GLOB]=""

#
# Backend, low level functions
#

# FUNCTION: .zinit-unregister-plugin [[[
# Removes the plugin from ZINIT_REGISTERED_PLUGINS array and from the
# zsh_loaded_plugins array (managed according to the plugin standard)
.zinit-unregister-plugin() {
    .zinit-any-to-user-plugin "$1" "$2"
    local uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" \
        teleid="$3"

    # If not found, the index will be length+1
    ZINIT_REGISTERED_PLUGINS[${ZINIT_REGISTERED_PLUGINS[(i)$uspl2]}]=()
    # Support Zsh plugin standard
    zsh_loaded_plugins[${zsh_loaded_plugins[(i)$teleid]}]=()
    ZINIT[STATES__$uspl2]="0"
} # ]]]
# FUNCTION: .zinit-diff-functions-compute [[[
# Computes FUNCTIONS that holds new functions added by plugin.
# Uses data gathered earlier by .zinit-diff-functions().
#
# $1 - user/plugin
.zinit-diff-functions-compute() {
    local uspl2="$1"

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces

    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[FUNCTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[FUNCTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A func
    local i

    # This includes new functions. Quoting is kept (i.e. no i=${(Q)i})
    for i in "${(z)ZINIT[FUNCTIONS_AFTER__$uspl2]}"; do
        func[$i]=1
    done

    # Remove duplicated entries, i.e. existing before. Quoting is kept
    for i in "${(z)ZINIT[FUNCTIONS_BEFORE__$uspl2]}"; do
        # if would do unset, then: func[opp+a\[]: invalid parameter name
        func[$i]=0
    done

    # Store the functions, associating them with plugin ($uspl2)
    ZINIT[FUNCTIONS__$uspl2]=""
    for i in "${(onk)func[@]}"; do
        [[ "${func[$i]}" = "1" ]] && ZINIT[FUNCTIONS__$uspl2]+="$i "
    done

    return 0
} # ]]]
# FUNCTION: .zinit-diff-options-compute [[[
# Computes OPTIONS that holds options changed by plugin.
# Uses data gathered earlier by .zinit-diff-options().
#
# $1 - user/plugin
.zinit-diff-options-compute() {
    local uspl2="$1"

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[OPTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[OPTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A opts_before opts_after opts
    opts_before=( "${(z)ZINIT[OPTIONS_BEFORE__$uspl2]}" )
    opts_after=( "${(z)ZINIT[OPTIONS_AFTER__$uspl2]}" )
    opts=( )

    # Iterate through first array (keys the same
    # on both of them though) and test for a change
    local key
    for key in "${(k)opts_before[@]}"; do
        if [[ "${opts_before[$key]}" != "${opts_after[$key]}" ]]; then
            opts[$key]="${opts_before[$key]}"
        fi
    done

    # Serialize for reporting
    local IFS=" "
    ZINIT[OPTIONS__$uspl2]="${(kv)opts[@]}"
    return 0
} # ]]]
# FUNCTION: .zinit-diff-env-compute [[[
# Computes ZINIT_PATH, ZINIT_FPATH that hold (f)path components
# added by plugin. Uses data gathered earlier by .zinit-diff-env().
#
# $1 - user/plugin
.zinit-diff-env-compute() {
    local uspl2="$1"
    typeset -a tmp

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[PATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
    [[ "${ZINIT[FPATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[FPATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A path_state fpath_state
    local i

    #
    # PATH processing
    #

    # This includes new path elements
    for i in "${(z)ZINIT[PATH_AFTER__$uspl2]}"; do
        path_state[${(Q)i}]=1
    done

    # Remove duplicated entries, i.e. existing before
    for i in "${(z)ZINIT[PATH_BEFORE__$uspl2]}"; do
        unset "path_state[${(Q)i}]"
    done

    # Store the path elements, associating them with plugin ($uspl2)
    ZINIT[PATH__$uspl2]=""
    for i in "${(onk)path_state[@]}"; do
        ZINIT[PATH__$uspl2]+="${(q)i} "
    done

    #
    # FPATH processing
    #

    # This includes new path elements
    for i in "${(z)ZINIT[FPATH_AFTER__$uspl2]}"; do
        fpath_state[${(Q)i}]=1
    done

    # Remove duplicated entries, i.e. existing before
    for i in "${(z)ZINIT[FPATH_BEFORE__$uspl2]}"; do
        unset "fpath_state[${(Q)i}]"
    done

    # Store the path elements, associating them with plugin ($uspl2)
    ZINIT[FPATH__$uspl2]=""
    for i in "${(onk)fpath_state[@]}"; do
        ZINIT[FPATH__$uspl2]+="${(q)i} "
    done

    return 0
} # ]]]
# FUNCTION: .zinit-diff-parameter-compute [[[
# Computes ZINIT_PARAMETERS_PRE, ZINIT_PARAMETERS_POST that hold
# parameters created or changed (their type) by plugin. Uses
# data gathered earlier by .zinit-diff-parameter().
#
# $1 - user/plugin
.zinit-diff-parameter-compute() {
    local uspl2="$1"
    typeset -a tmp

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[PARAMETERS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PARAMETERS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    # Un-concatenated parameters from moment of diff start and of diff end
    typeset -A params_before params_after
    params_before=( "${(z)ZINIT[PARAMETERS_BEFORE__$uspl2]}" )
    params_after=( "${(z)ZINIT[PARAMETERS_AFTER__$uspl2]}" )

    # The parameters that changed, with save of what
    # parameter was when diff started or when diff ended
    typeset -A params_pre params_post
    params_pre=( )
    params_post=( )

    # Iterate through all existing keys, before or after diff,
    # i.e. after all variables that were somehow live across
    # the diffing process
    local key
    typeset -aU keys
    keys=( "${(k)params_after[@]}" );
    keys=( "${keys[@]}" "${(k)params_before[@]}" );
    for key in "${keys[@]}"; do
        key="${(Q)key}"
        [[ "${params_after[$key]}" = *local* ]] && continue
        if [[ "${params_after[$key]}" != "${params_before[$key]}" ]]; then
            # Empty for a new param, a type otherwise
            [[ -z "${params_before[$key]}" ]] && params_before[$key]="\"\""
            params_pre[$key]="${params_before[$key]}"

            # Current type, can also be empty, when plugin
            # unsets a parameter
            [[ -z "${params_after[$key]}" ]] && params_after[$key]="\"\""
            params_post[$key]="${params_after[$key]}"
        fi
    done

    # Serialize for reporting
    ZINIT[PARAMETERS_PRE__$uspl2]="${(j: :)${(qkv)params_pre[@]}}"
    ZINIT[PARAMETERS_POST__$uspl2]="${(j: :)${(qkv)params_post[@]}}"

    return 0
} # ]]]
# FUNCTION: .zinit-any-to-uspl2 [[[
# Converts given plugin-spec to format that's used in keys for hash tables.
# So basically, creates string "user/plugin" (this format is called: uspl2).
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-any-to-uspl2() {
    .zinit-any-to-user-plugin "$1" "$2"
    [[ "${reply[-2]}" = "%" ]] && REPLY="${reply[-2]}${reply[-1]}" || REPLY="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]//---//}"
} # ]]]
# FUNCTION: .zinit-save-set-extendedglob [[[
# Enables extendedglob-option first saving if it was already
# enabled, for restoration of this state later.
.zinit-save-set-extendedglob() {
    [[ -o "extendedglob" ]] && ZINIT[EXTENDED_GLOB]="1" || ZINIT[EXTENDED_GLOB]="0"
    builtin setopt extendedglob
} # ]]]
# FUNCTION: .zinit-restore-extendedglob [[[
# Restores extendedglob-option from state saved earlier.
.zinit-restore-extendedglob() {
    [[ "${ZINIT[EXTENDED_GLOB]}" = "0" ]] && builtin unsetopt extendedglob || builtin setopt extendedglob
} # ]]]
# FUNCTION: .zinit-prepare-readlink [[[
# Prepares readlink command, used for establishing completion's owner.
#
# $REPLY = ":" or "readlink"
.zinit-prepare-readlink() {
    REPLY=":"
    if type readlink 2>/dev/null 1>&2; then
        REPLY="readlink"
    fi
} # ]]]
# FUNCTION: .zinit-clear-report-for [[[
# Clears all report data for given user/plugin. This is
# done by resetting all related global ZINIT_* hashes.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-clear-report-for() {
    .zinit-any-to-uspl2 "$1" "$2"

    # Shadowing
    ZINIT_REPORTS[$REPLY]=""
    ZINIT[BINDKEYS__$REPLY]=""
    ZINIT[ZSTYLES__$REPLY]=""
    ZINIT[ALIASES__$REPLY]=""
    ZINIT[WIDGETS_SAVED__$REPLY]=""
    ZINIT[WIDGETS_DELETE__$REPLY]=""

    # Function diffing
    ZINIT[FUNCTIONS__$REPLY]=""
    ZINIT[FUNCTIONS_BEFORE__$REPLY]=""
    ZINIT[FUNCTIONS_AFTER__$REPLY]=""

    # Option diffing
    ZINIT[OPTIONS__$REPLY]=""
    ZINIT[OPTIONS_BEFORE__$REPLY]=""
    ZINIT[OPTIONS_AFTER__$REPLY]=""

    # Environment diffing
    ZINIT[PATH__$REPLY]=""
    ZINIT[PATH_BEFORE__$REPLY]=""
    ZINIT[PATH_AFTER__$REPLY]=""
    ZINIT[FPATH__$REPLY]=""
    ZINIT[FPATH_BEFORE__$REPLY]=""
    ZINIT[FPATH_AFTER__$REPLY]=""

    # Parameter diffing
    ZINIT[PARAMETERS_PRE__$REPLY]=""
    ZINIT[PARAMETERS_POST__$REPLY]=""
    ZINIT[PARAMETERS_BEFORE__$REPLY]=""
    ZINIT[PARAMETERS_AFTER__$REPLY]=""
} # ]]]
# FUNCTION: .zinit-exists-message [[[
# Checks if plugin is loaded. Testable. Also outputs error
# message if plugin is not loaded.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-exists-message() {
    .zinit-any-to-uspl2 "$1" "$2"
    if [[ -z "${ZINIT_REGISTERED_PLUGINS[(r)$REPLY]}" ]]; then
        .zinit-any-colorify-as-uspl2 "$1" "$2"
        builtin print "${ZINIT[col-error]}No such plugin${ZINIT[col-rst]} $REPLY"
        return 1
    fi
    return 0
} # ]]]
# FUNCTION: .zinit-at-eval [[[
.zinit-at-eval() {
    local atclone="$2" atpull="$1"
    integer retval
    @zinit-substitute atclone atpull
    [[ $atpull = "%atclone" ]] && { eval "$atclone"; retval=$?; } || { eval "$atpull"; retval=$?; }
    return $retval
} # ]]]

#
# Format functions
#

# FUNCTION: .zinit-format-functions [[[
# Creates a one or two columns text with functions created
# by given plugin.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-functions() {
    local uspl2="$1"

    typeset -a func
    func=( "${(z)ZINIT[FUNCTIONS__$uspl2]}" )

    # Get length of longest left-right string pair,
    # and length of longest left string
    integer longest=0 longest_left=0 cur_left_len=0 count=1
    local f
    for f in "${(on)func[@]}"; do
        [[ -z "${#f}" ]] && continue
        f="${(Q)f}"

        # Compute for elements in left column,
        # ones that will be paded with spaces
        if (( count ++ % 2 != 0 )); then
            [[ "${#f}" -gt "$longest_left" ]] && longest_left="${#f}"
            cur_left_len="${#f}"
        else
            cur_left_len+="${#f}"
            cur_left_len+=1 # For separating space
            [[ "$cur_left_len" -gt "$longest" ]] && longest="$cur_left_len"
        fi
    done

    # Output in one or two columns
    local answer=""
    count=1
    for f in "${(on)func[@]}"; do
        [[ -z "$f" ]] && continue
        f="${(Q)f}"

        if (( COLUMNS >= longest )); then
            if (( count ++ % 2 != 0 )); then
                answer+="${(r:longest_left+1:: :)f}"
            else
                answer+="$f"$'\n'
            fi
        else
            answer+="$f"$'\n'
        fi
    done
    REPLY="$answer"
    # == 0 is: next element would have newline (postfix addition in "count ++")
    (( COLUMNS >= longest && count % 2 == 0 )) && REPLY="$REPLY"$'\n'
} # ]]]
# FUNCTION: .zinit-format-options [[[
# Creates one-column text about options that changed when
# plugin "$1" was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-options() {
    local uspl2="$1"

    REPLY=""

    # Paranoid, don't want bad key/value pair error
    integer empty=0
    .zinit-save-set-extendedglob
    [[ "${ZINIT[OPTIONS__$uspl2]}" != *[$'! \t']* ]] && empty=1
    .zinit-restore-extendedglob
    (( empty )) && return 0

    typeset -A opts
    opts=( "${(z)ZINIT[OPTIONS__$uspl2]}" )

    # Get length of longest option
    integer longest=0
    local k
    for k in "${(kon)opts[@]}"; do
        [[ "${#k}" -gt "$longest" ]] && longest="${#k}"
    done

    # Output in one column
    local txt
    for k in "${(kon)opts[@]}"; do
        [[ "${opts[$k]}" = "on" ]] && txt="was unset" || txt="was set"
        REPLY+="${(r:longest+1:: :)k}$txt"$'\n'
    done
} # ]]]
# FUNCTION: .zinit-format-env [[[
# Creates one-column text about FPATH or PATH elements
# added when given plugin was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
# $2 - if 1, then examine PATH, if 2, then examine FPATH
.zinit-format-env() {
    local uspl2="$1" which="$2"

    # Format PATH?
    if [[ "$which" = "1" ]]; then
        typeset -a elem
        elem=( "${(z@)ZINIT[PATH__$uspl2]}" )
    elif [[ "$which" = "2" ]]; then
        typeset -a elem
        elem=( "${(z@)ZINIT[FPATH__$uspl2]}" )
    fi

    # Enumerate elements added
    local answer="" e
    for e in "${elem[@]}"; do
        [[ -z "$e" ]] && continue
        e="${(Q)e}"
        answer+="$e"$'\n'
    done

    [[ -n "$answer" ]] && REPLY="$answer"
} # ]]]
# FUNCTION: .zinit-format-parameter [[[
# Creates one column text that lists global parameters that
# changed when the given plugin was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-parameter() {
    local uspl2="$1" infoc="${ZINIT[col-info]}" k

    builtin setopt localoptions extendedglob nokshglob noksharrays
    REPLY=""
    [[ "${ZINIT[PARAMETERS_PRE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PARAMETERS_POST__$uspl2]}" != *[$'! \t']* ]] && return 0

    typeset -A elem_pre elem_post
    elem_pre=( "${(z)ZINIT[PARAMETERS_PRE__$uspl2]}" )
    elem_post=( "${(z)ZINIT[PARAMETERS_POST__$uspl2]}" )

    # Find longest key and longest value
    integer longest=0 vlongest1=0 vlongest2=0
    local v1 v2
    for k in "${(k)elem_post[@]}"; do
        k="${(Q)k}"
        [[ "${#k}" -gt "$longest" ]] && longest="${#k}"

        v1="${(Q)elem_pre[$k]}"
        v2="${(Q)elem_post[$k]}"
        [[ "${#v1}" -gt "$vlongest1" ]] && vlongest1="${#v1}"
        [[ "${#v2}" -gt "$vlongest2" ]] && vlongest2="${#v2}"
    done

    # Enumerate parameters that changed. A key
    # always exists in both of the arrays
    local answer="" k
    for k in "${(k)elem_post[@]}"; do
        v1="${(Q)elem_pre[$k]}"
        v2="${(Q)elem_post[$k]}"
        k="${(Q)k}"

        k="${(r:longest+1:: :)k}"
        v1="${(l:vlongest1+1:: :)v1}"
        v2="${(r:vlongest2+1:: :)v2}"
        answer+="$k ${infoc}[$v1 -> $v2]${ZINIT[col-rst]}"$'\n'
    done

    [[ -n "$answer" ]] && REPLY="$answer"

    return 0
} # ]]]

#
# Completion functions
#

# FUNCTION: .zinit-get-completion-owner [[[
# Returns "user---plugin" string (uspl1 format) of plugin that
# owns given completion.
#
# Both :A and readlink will be used, then readlink's output if
# results differ. Readlink might not be available.
#
# :A will read the link "twice" and give the final repository
# directory, possibly without username in the uspl format;
# readlink will read the link "once"
#
# $1 - absolute path to completion file (in COMPLETIONS_DIR)
# $2 - readlink command (":" or "readlink")
.zinit-get-completion-owner() {
    setopt localoptions extendedglob nokshglob noksharrays noshwordsplit
    local cpath="$1"
    local readlink_cmd="$2"
    local in_plugin_path tmp

    # Try to go not too deep into resolving the symlink,
    # to have the name as it is in .zinit/plugins
    # :A goes deep, descends fully to origin directory
    # Readlink just reads what symlink points to
    in_plugin_path="${cpath:A}"
    tmp=$( "$readlink_cmd" "$cpath" )
    # This in effect works as: "if different, then readlink"
    [[ -n "$tmp" ]] && in_plugin_path="$tmp"

    if [[ "$in_plugin_path" != "$cpath" && -r "$in_plugin_path" ]]; then
        # Get the user---plugin part of path
        while [[ "$in_plugin_path" != ${ZINIT[PLUGINS_DIR]}/[^/]## && "$in_plugin_path" != "/" && "$in_plugin_path" != "." ]]; do
            in_plugin_path="${in_plugin_path:h}"
        done
        in_plugin_path="${in_plugin_path:t}"

        if [[ -z "$in_plugin_path" ]]; then
            in_plugin_path="${tmp:h}"
        fi
    else
        # readlink and :A have nothing
        in_plugin_path="[unknown]"
    fi

    REPLY="$in_plugin_path"
} # ]]]
# FUNCTION: .zinit-get-completion-owner-uspl2col [[[
# For shortening of code - returns colorized plugin name
# that owns given completion.
#
# $1 - absolute path to completion file (in COMPLETIONS_DIR)
# $2 - readlink command (":" or "readlink")
.zinit-get-completion-owner-uspl2col() {
    # "cpath" "readline_cmd"
    .zinit-get-completion-owner "$1" "$2"
    .zinit-any-colorify-as-uspl2 "$REPLY"
} # ]]]
# FUNCTION: .zinit-find-completions-of-plugin [[[
# Searches for completions owned by given plugin.
# Returns them in `reply' array.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-find-completions-of-plugin() {
    builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
    .zinit-any-to-user-plugin "$1" "$2"
    local user="${reply[-2]}" plugin="${reply[-1]}" uspl
    [[ "$user" = "%" ]] && uspl="${user}${plugin}" || uspl="${reply[-2]}${reply[-2]:+---}${reply[-1]//\//---}"

    reply=( "${ZINIT[PLUGINS_DIR]}/$uspl"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
} # ]]]
# FUNCTION: .zinit-check-comp-consistency [[[
# Zinit creates symlink for each installed completion.
# This function checks whether given completion (i.e.
# file like "_mkdir") is indeed a symlink. Backup file
# is a completion that is disabled - has the leading "_"
# removed.
#
# $1 - path to completion within plugin's directory
# $2 - path to backup file within plugin's directory
.zinit-check-comp-consistency() {
    local cfile="$1" bkpfile="$2"
    integer error="$3"

    # bkpfile must be a symlink
    if [[ -e "$bkpfile" && ! -L "$bkpfile" ]]; then
        builtin print "${ZINIT[col-error]}Warning: completion's backup file \`${bkpfile:t}' isn't a symlink${ZINIT[col-rst]}"
        error=1
    fi

    # cfile must be a symlink
    if [[ -e "$cfile" && ! -L "$cfile" ]]; then
        builtin print "${ZINIT[col-error]}Warning: completion file \`${cfile:t}' isn't a symlink${ZINIT[col-rst]}"
        error=1
    fi

    # Tell user that he can manually modify but should do it right
    (( error )) && builtin print "${ZINIT[col-error]}Manual edit of ${ZINIT[COMPLETIONS_DIR]} occured?${ZINIT[col-rst]}"
} # ]]]
# FUNCTION: .zinit-check-which-completions-are-installed [[[
# For each argument that each should be a path to completion
# within a plugin's dir, it checks whether that completion
# is installed - returns 0 or 1 on corresponding positions
# in reply.
#
# $1, ... - path to completion within plugin's directory
.zinit-check-which-completions-are-installed() {
    local i cfile bkpfile
    reply=( )
    for i in "$@"; do
        cfile="${i:t}"
        bkpfile="${cfile#_}"

        if [[ -e "${ZINIT[COMPLETIONS_DIR]}"/"$cfile" || -e "${ZINIT[COMPLETIONS_DIR]}"/"$bkpfile" ]]; then
            reply+=( "1" )
        else
            reply+=( "0" )
        fi
    done
} # ]]]
# FUNCTION: .zinit-check-which-completions-are-enabled [[[
# For each argument that each should be a path to completion
# within a plugin's dir, it checks whether that completion
# is disabled - returns 0 or 1 on corresponding positions
# in reply.
#
# Uninstalled completions will be reported as "0"
# - i.e. disabled
#
# $1, ... - path to completion within plugin's directory
.zinit-check-which-completions-are-enabled() {
    local i cfile
    reply=( )
    for i in "$@"; do
        cfile="${i:t}"

        if [[ -e "${ZINIT[COMPLETIONS_DIR]}"/"$cfile" ]]; then
            reply+=( "1" )
        else
            reply+=( "0" )
        fi
    done
} # ]]]
# FUNCTION: .zinit-uninstall-completions [[[
# Removes all completions of given plugin from Zshell (i.e. from FPATH).
# The FPATH is typically `~/.zinit/completions/'.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-uninstall-completions() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops

    typeset -a completions symlinked backup_comps
    local c cfile bkpfile
    integer action global_action=0

    .zinit-get-path "$1" "$2"
    [[ -e $REPLY ]] && {
        completions=( $REPLY/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
    } || {
        builtin print "No completions found for \`$1${${1:#(%|/)*}:+${2:+/}}$2'"
        return 1
    }

    symlinked=( ${ZINIT[COMPLETIONS_DIR]}/_[^_.]*~*.zwc )
    backup_comps=( ${ZINIT[COMPLETIONS_DIR]}/[^_.]*~*.zwc )

    (( ${+functions[.zinit-forget-completion]} )) || builtin source ${ZINIT[BIN_DIR]}"/zinit-install.zsh"

    # Delete completions if they are really there, either
    # as completions (_fname) or backups (fname)
    for c in ${completions[@]}; do
        action=0
        cfile=${c:t}
        bkpfile=${cfile#_}

        # Remove symlink to completion
        if [[ -n ${symlinked[(r)*/$cfile]} ]]; then
            command rm -f ${ZINIT[COMPLETIONS_DIR]}/$cfile
            action=1
        fi

        # Remove backup symlink (created by cdisable)
        if [[ -n ${backup_comps[(r)*/$bkpfile]} ]]; then
            command rm -f ${ZINIT[COMPLETIONS_DIR]}/$bkpfile
            action=1
        fi

        if (( action )); then
            +zi-log "{info}Uninstalling completion \`{file}$cfile{info}'{…}{rst}"
            # Make compinit notice the change
            .zinit-forget-completion "$cfile"
            (( global_action ++ ))
        else
            +zi-log "{info}Completion \`{file}$cfile{info}' not installed.{rst}"
        fi
    done

    if (( global_action > 0 )); then
        +zi-log "{info}Uninstalled {num}$global_action{info} completions.{rst}"
    fi

    .zinit-compinit >/dev/null
} # ]]]

#
# User-exposed functions
#

# FUNCTION: .zinit-pager [[[
# BusyBox less lacks the -X and -i options, so it can use more
.zinit-pager() {
    setopt LOCAL_OPTIONS EQUALS

    # Check if a non-interactive mode has been requested, either via a flag or a global setting.
    if (( OPTS[opt_-n,--no-pager] )) || [[ ${ZINIT[NO_PAGER]} = (1|true|on|yes) ]]; then
        # NON-INTERACTIVE MODE
        local max_lines=${ZINIT[NO_PAGER_MAX_LINES]}

        # Check if a line limit is explicitly set and is a valid non-negative integer.
        if [[ $max_lines =~ ^[0-9]+$ ]]; then
            if (( max_lines > 0 )); then
                # A positive number means limit the output to that many lines.
                head -n "$max_lines"
            else
                # A value of 0 means suppress all output from the pager completely.
                # `cat > /dev/null` is the most robust way to achieve this.
                cat > /dev/null
            fi
        else
            # No valid line limit is set, so show the full output without interaction.
            cat
        fi
        return 0
    else
        # INTERACTIVE MODE (Original Behavior)
        # Fall back to the default interactive pager if no non-interactive mode is set.
        if [[ ${${:-=less}:A:t} = busybox* ]] {
            more 2>/dev/null
            (( ${+commands[more]} ))
        } else {
            less -FRXi 2>/dev/null
            (( ${+commands[less]} ))
        }
        (( $? )) && cat
        return 0
    fi
} # ]]]

# FUNCTION: .zinit-build-module [[[
# Performs ./configure && make on the module and displays information
# how to load the module in .zshrc.
.zinit-build-module() {
    setopt localoptions localtraps
    trap 'return 1' INT TERM
    if command git -C "${ZINIT[MODULE_DIR]}" rev-parse 2>/dev/null; then
        command git -C "${ZINIT[MODULE_DIR]}" clean -d -f -f
        command git -C "${ZINIT[MODULE_DIR]}" reset --hard HEAD
        command git -C "${ZINIT[MODULE_DIR]}" pull
    else
        command git clone "https://github.com/zdharma-continuum/zinit-module.git" "${ZINIT[MODULE_DIR]}" || {
            builtin print "${ZINIT[col-error]}Failed to clone module repo${ZINIT[col-rst]}"
            return 1
        }
    fi
    ( builtin cd -q "${ZINIT[MODULE_DIR]}"
      +zi-log "{pname}== Building module zdharma-continuum/zinit-module, running: make clean, then ./configure and then make =={rst}"
      +zi-log "{pname}== The module sources are located at: "${ZINIT[MODULE_DIR]}" =={rst}"
      if [[ -f Makefile ]] {
          if [[ "$1" = "--clean" ]] {
              noglob +zi-log {p}-- make distclean --{rst}
              make distclean
              ((1))
          } else {
              noglob +zi-log {p}-- make clean --{rst}
              make clean
          }
      }
      noglob +zi-log  {p}-- ./configure --{rst}
      CPPFLAGS=-I/usr/local/include CFLAGS="-g -Wall -O3" LDFLAGS=-L/usr/local/lib ./configure --disable-gdbm --without-tcsetpgrp && {
          noglob +zi-log {p}-- make --{rst}
          if { make } {
            [[ -f Src/zdharma_continuum/zinit.so ]] && cp -vf Src/zdharma_continuum/zinit.{so,bundle}
            noglob +zi-log "{info}Module has been built correctly.{rst}"
            .zinit-module info
          } else {
              noglob +zi-log  "{error}Module didn't build.{rst} "
              .zinit-module info --link
          }
      }
      builtin print $EPOCHSECONDS >! "${ZINIT[MAN_DIR]}/COMPILED_AT"
    )
} # ]]]
# FUNCTION: .zinit-module [[[
# Function that has sub-commands passed as long-options (with two dashes, --).
# It's an attempt to plugin only this one function into `zinit' function
# defined in zinit.zsh, to not make this file longer than it's needed.
.zinit-module() {
    if [[ "$1" = "build" ]]; then
        .zinit-build-module "${@[2,-1]}"
    elif [[ "$1" = "info" ]]; then
        if [[ "$2" = "--link" ]]; then
              builtin print -r "You can copy the error messages and submit"
              builtin print -r "error-report at: https://github.com/zdharma-continuum/zinit-module/issues"
        else
            builtin print -r "To load the module, add following 2 lines to .zshrc, at top:"
            builtin print -r "    module_path+=( \"${ZINIT[MODULE_DIR]}/Src\" )"
            builtin print -r "    zmodload zdharma_continuum/zinit"
            builtin print -r ""
            builtin print -r "After loading, use command \`zpmod' to communicate with the module."
            builtin print -r "See \`zpmod -h' for more information."
        fi
    elif [[ "$1" = (help|usage) ]]; then
        builtin print -r "Usage: zinit module {build|info|help} [options]"
        builtin print -r "       zinit module build [--clean]"
        builtin print -r "       zinit module info [--link]"
        builtin print -r ""
        builtin print -r "To start using the zinit Zsh module run: \`zinit module build'"
        builtin print -r "and follow the instructions. Option --clean causes \`make distclean'"
        builtin print -r "to be run. To display the instructions on loading the module, run:"
... truncated; 2,816 more lines
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/zinit/zinit-autoload.zsh — 3,616 LOC
#!/usr/bin/env zsh
#
# zdharma-continuum/zinit/zinit-autoload.zsh
# Copyright (c) 2016-2021 Sebastian Gniazdowski
# Copyright (c) 2021-2023 zdharma-continuum
# Homepage: https://github.com/zdharma-continuum/zinit
# License: MIT License
#

builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { builtin print -P "${ZINIT[col-error]}ERROR:%f%b Couldn't find ${ZINIT[col-obj]}zinit-side.zsh%f%b."; return 1; }

ZINIT[EXTENDED_GLOB]=""

#
# Backend, low level functions
#

# FUNCTION: .zinit-unregister-plugin [[[
# Removes the plugin from ZINIT_REGISTERED_PLUGINS array and from the
# zsh_loaded_plugins array (managed according to the plugin standard)
.zinit-unregister-plugin() {
    .zinit-any-to-user-plugin "$1" "$2"
    local uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" \
        teleid="$3"

    # If not found, the index will be length+1
    ZINIT_REGISTERED_PLUGINS[${ZINIT_REGISTERED_PLUGINS[(i)$uspl2]}]=()
    # Support Zsh plugin standard
    zsh_loaded_plugins[${zsh_loaded_plugins[(i)$teleid]}]=()
    ZINIT[STATES__$uspl2]="0"
} # ]]]
# FUNCTION: .zinit-diff-functions-compute [[[
# Computes FUNCTIONS that holds new functions added by plugin.
# Uses data gathered earlier by .zinit-diff-functions().
#
# $1 - user/plugin
.zinit-diff-functions-compute() {
    local uspl2="$1"

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces

    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[FUNCTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[FUNCTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A func
    local i

    # This includes new functions. Quoting is kept (i.e. no i=${(Q)i})
    for i in "${(z)ZINIT[FUNCTIONS_AFTER__$uspl2]}"; do
        func[$i]=1
    done

    # Remove duplicated entries, i.e. existing before. Quoting is kept
    for i in "${(z)ZINIT[FUNCTIONS_BEFORE__$uspl2]}"; do
        # if would do unset, then: func[opp+a\[]: invalid parameter name
        func[$i]=0
    done

    # Store the functions, associating them with plugin ($uspl2)
    ZINIT[FUNCTIONS__$uspl2]=""
    for i in "${(onk)func[@]}"; do
        [[ "${func[$i]}" = "1" ]] && ZINIT[FUNCTIONS__$uspl2]+="$i "
    done

    return 0
} # ]]]
# FUNCTION: .zinit-diff-options-compute [[[
# Computes OPTIONS that holds options changed by plugin.
# Uses data gathered earlier by .zinit-diff-options().
#
# $1 - user/plugin
.zinit-diff-options-compute() {
    local uspl2="$1"

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[OPTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[OPTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A opts_before opts_after opts
    opts_before=( "${(z)ZINIT[OPTIONS_BEFORE__$uspl2]}" )
    opts_after=( "${(z)ZINIT[OPTIONS_AFTER__$uspl2]}" )
    opts=( )

    # Iterate through first array (keys the same
    # on both of them though) and test for a change
    local key
    for key in "${(k)opts_before[@]}"; do
        if [[ "${opts_before[$key]}" != "${opts_after[$key]}" ]]; then
            opts[$key]="${opts_before[$key]}"
        fi
    done

    # Serialize for reporting
    local IFS=" "
    ZINIT[OPTIONS__$uspl2]="${(kv)opts[@]}"
    return 0
} # ]]]
# FUNCTION: .zinit-diff-env-compute [[[
# Computes ZINIT_PATH, ZINIT_FPATH that hold (f)path components
# added by plugin. Uses data gathered earlier by .zinit-diff-env().
#
# $1 - user/plugin
.zinit-diff-env-compute() {
    local uspl2="$1"
    typeset -a tmp

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[PATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
    [[ "${ZINIT[FPATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[FPATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A path_state fpath_state
    local i

    #
    # PATH processing
    #

    # This includes new path elements
    for i in "${(z)ZINIT[PATH_AFTER__$uspl2]}"; do
        path_state[${(Q)i}]=1
    done

    # Remove duplicated entries, i.e. existing before
    for i in "${(z)ZINIT[PATH_BEFORE__$uspl2]}"; do
        unset "path_state[${(Q)i}]"
    done

    # Store the path elements, associating them with plugin ($uspl2)
    ZINIT[PATH__$uspl2]=""
    for i in "${(onk)path_state[@]}"; do
        ZINIT[PATH__$uspl2]+="${(q)i} "
    done

    #
    # FPATH processing
    #

    # This includes new path elements
    for i in "${(z)ZINIT[FPATH_AFTER__$uspl2]}"; do
        fpath_state[${(Q)i}]=1
    done

    # Remove duplicated entries, i.e. existing before
    for i in "${(z)ZINIT[FPATH_BEFORE__$uspl2]}"; do
        unset "fpath_state[${(Q)i}]"
    done

    # Store the path elements, associating them with plugin ($uspl2)
    ZINIT[FPATH__$uspl2]=""
    for i in "${(onk)fpath_state[@]}"; do
        ZINIT[FPATH__$uspl2]+="${(q)i} "
    done

    return 0
} # ]]]
# FUNCTION: .zinit-diff-parameter-compute [[[
# Computes ZINIT_PARAMETERS_PRE, ZINIT_PARAMETERS_POST that hold
# parameters created or changed (their type) by plugin. Uses
# data gathered earlier by .zinit-diff-parameter().
#
# $1 - user/plugin
.zinit-diff-parameter-compute() {
    local uspl2="$1"
    typeset -a tmp

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[PARAMETERS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PARAMETERS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    # Un-concatenated parameters from moment of diff start and of diff end
    typeset -A params_before params_after
    params_before=( "${(z)ZINIT[PARAMETERS_BEFORE__$uspl2]}" )
    params_after=( "${(z)ZINIT[PARAMETERS_AFTER__$uspl2]}" )

    # The parameters that changed, with save of what
    # parameter was when diff started or when diff ended
    typeset -A params_pre params_post
    params_pre=( )
    params_post=( )

    # Iterate through all existing keys, before or after diff,
    # i.e. after all variables that were somehow live across
    # the diffing process
    local key
    typeset -aU keys
    keys=( "${(k)params_after[@]}" );
    keys=( "${keys[@]}" "${(k)params_before[@]}" );
    for key in "${keys[@]}"; do
        key="${(Q)key}"
        [[ "${params_after[$key]}" = *local* ]] && continue
        if [[ "${params_after[$key]}" != "${params_before[$key]}" ]]; then
            # Empty for a new param, a type otherwise
            [[ -z "${params_before[$key]}" ]] && params_before[$key]="\"\""
            params_pre[$key]="${params_before[$key]}"

            # Current type, can also be empty, when plugin
            # unsets a parameter
            [[ -z "${params_after[$key]}" ]] && params_after[$key]="\"\""
            params_post[$key]="${params_after[$key]}"
        fi
    done

    # Serialize for reporting
    ZINIT[PARAMETERS_PRE__$uspl2]="${(j: :)${(qkv)params_pre[@]}}"
    ZINIT[PARAMETERS_POST__$uspl2]="${(j: :)${(qkv)params_post[@]}}"

    return 0
} # ]]]
# FUNCTION: .zinit-any-to-uspl2 [[[
# Converts given plugin-spec to format that's used in keys for hash tables.
# So basically, creates string "user/plugin" (this format is called: uspl2).
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-any-to-uspl2() {
    .zinit-any-to-user-plugin "$1" "$2"
    [[ "${reply[-2]}" = "%" ]] && REPLY="${reply[-2]}${reply[-1]}" || REPLY="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]//---//}"
} # ]]]
# FUNCTION: .zinit-save-set-extendedglob [[[
# Enables extendedglob-option first saving if it was already
# enabled, for restoration of this state later.
.zinit-save-set-extendedglob() {
    [[ -o "extendedglob" ]] && ZINIT[EXTENDED_GLOB]="1" || ZINIT[EXTENDED_GLOB]="0"
    builtin setopt extendedglob
} # ]]]
# FUNCTION: .zinit-restore-extendedglob [[[
# Restores extendedglob-option from state saved earlier.
.zinit-restore-extendedglob() {
    [[ "${ZINIT[EXTENDED_GLOB]}" = "0" ]] && builtin unsetopt extendedglob || builtin setopt extendedglob
} # ]]]
# FUNCTION: .zinit-prepare-readlink [[[
# Prepares readlink command, used for establishing completion's owner.
#
# $REPLY = ":" or "readlink"
.zinit-prepare-readlink() {
    REPLY=":"
    if type readlink 2>/dev/null 1>&2; then
        REPLY="readlink"
    fi
} # ]]]
# FUNCTION: .zinit-clear-report-for [[[
# Clears all report data for given user/plugin. This is
# done by resetting all related global ZINIT_* hashes.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-clear-report-for() {
    .zinit-any-to-uspl2 "$1" "$2"

    # Shadowing
    ZINIT_REPORTS[$REPLY]=""
    ZINIT[BINDKEYS__$REPLY]=""
    ZINIT[ZSTYLES__$REPLY]=""
    ZINIT[ALIASES__$REPLY]=""
    ZINIT[WIDGETS_SAVED__$REPLY]=""
    ZINIT[WIDGETS_DELETE__$REPLY]=""

    # Function diffing
    ZINIT[FUNCTIONS__$REPLY]=""
    ZINIT[FUNCTIONS_BEFORE__$REPLY]=""
    ZINIT[FUNCTIONS_AFTER__$REPLY]=""

    # Option diffing
    ZINIT[OPTIONS__$REPLY]=""
    ZINIT[OPTIONS_BEFORE__$REPLY]=""
    ZINIT[OPTIONS_AFTER__$REPLY]=""

    # Environment diffing
    ZINIT[PATH__$REPLY]=""
    ZINIT[PATH_BEFORE__$REPLY]=""
    ZINIT[PATH_AFTER__$REPLY]=""
    ZINIT[FPATH__$REPLY]=""
    ZINIT[FPATH_BEFORE__$REPLY]=""
    ZINIT[FPATH_AFTER__$REPLY]=""

    # Parameter diffing
    ZINIT[PARAMETERS_PRE__$REPLY]=""
    ZINIT[PARAMETERS_POST__$REPLY]=""
    ZINIT[PARAMETERS_BEFORE__$REPLY]=""
    ZINIT[PARAMETERS_AFTER__$REPLY]=""
} # ]]]
# FUNCTION: .zinit-exists-message [[[
# Checks if plugin is loaded. Testable. Also outputs error
# message if plugin is not loaded.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-exists-message() {
    .zinit-any-to-uspl2 "$1" "$2"
    if [[ -z "${ZINIT_REGISTERED_PLUGINS[(r)$REPLY]}" ]]; then
        .zinit-any-colorify-as-uspl2 "$1" "$2"
        builtin print "${ZINIT[col-error]}No such plugin${ZINIT[col-rst]} $REPLY"
        return 1
    fi
    return 0
} # ]]]
# FUNCTION: .zinit-at-eval [[[
.zinit-at-eval() {
    local atclone="$2" atpull="$1"
    integer retval
    @zinit-substitute atclone atpull
    [[ $atpull = "%atclone" ]] && { eval "$atclone"; retval=$?; } || { eval "$atpull"; retval=$?; }
    return $retval
} # ]]]

#
# Format functions
#

# FUNCTION: .zinit-format-functions [[[
# Creates a one or two columns text with functions created
# by given plugin.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-functions() {
    local uspl2="$1"

    typeset -a func
    func=( "${(z)ZINIT[FUNCTIONS__$uspl2]}" )

    # Get length of longest left-right string pair,
    # and length of longest left string
    integer longest=0 longest_left=0 cur_left_len=0 count=1
    local f
    for f in "${(on)func[@]}"; do
        [[ -z "${#f}" ]] && continue
        f="${(Q)f}"

        # Compute for elements in left column,
        # ones that will be paded with spaces
        if (( count ++ % 2 != 0 )); then
            [[ "${#f}" -gt "$longest_left" ]] && longest_left="${#f}"
            cur_left_len="${#f}"
        else
            cur_left_len+="${#f}"
            cur_left_len+=1 # For separating space
            [[ "$cur_left_len" -gt "$longest" ]] && longest="$cur_left_len"
        fi
    done

    # Output in one or two columns
    local answer=""
    count=1
    for f in "${(on)func[@]}"; do
        [[ -z "$f" ]] && continue
        f="${(Q)f}"

        if (( COLUMNS >= longest )); then
            if (( count ++ % 2 != 0 )); then
                answer+="${(r:longest_left+1:: :)f}"
            else
                answer+="$f"$'\n'
            fi
        else
            answer+="$f"$'\n'
        fi
    done
    REPLY="$answer"
    # == 0 is: next element would have newline (postfix addition in "count ++")
    (( COLUMNS >= longest && count % 2 == 0 )) && REPLY="$REPLY"$'\n'
} # ]]]
# FUNCTION: .zinit-format-options [[[
# Creates one-column text about options that changed when
# plugin "$1" was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-options() {
    local uspl2="$1"

    REPLY=""

    # Paranoid, don't want bad key/value pair error
    integer empty=0
    .zinit-save-set-extendedglob
    [[ "${ZINIT[OPTIONS__$uspl2]}" != *[$'! \t']* ]] && empty=1
    .zinit-restore-extendedglob
    (( empty )) && return 0

    typeset -A opts
    opts=( "${(z)ZINIT[OPTIONS__$uspl2]}" )

    # Get length of longest option
    integer longest=0
    local k
    for k in "${(kon)opts[@]}"; do
        [[ "${#k}" -gt "$longest" ]] && longest="${#k}"
    done

    # Output in one column
    local txt
    for k in "${(kon)opts[@]}"; do
        [[ "${opts[$k]}" = "on" ]] && txt="was unset" || txt="was set"
        REPLY+="${(r:longest+1:: :)k}$txt"$'\n'
    done
} # ]]]
# FUNCTION: .zinit-format-env [[[
# Creates one-column text about FPATH or PATH elements
# added when given plugin was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
# $2 - if 1, then examine PATH, if 2, then examine FPATH
.zinit-format-env() {
    local uspl2="$1" which="$2"

    # Format PATH?
    if [[ "$which" = "1" ]]; then
        typeset -a elem
        elem=( "${(z@)ZINIT[PATH__$uspl2]}" )
    elif [[ "$which" = "2" ]]; then
        typeset -a elem
        elem=( "${(z@)ZINIT[FPATH__$uspl2]}" )
    fi

    # Enumerate elements added
    local answer="" e
    for e in "${elem[@]}"; do
        [[ -z "$e" ]] && continue
        e="${(Q)e}"
        answer+="$e"$'\n'
    done

    [[ -n "$answer" ]] && REPLY="$answer"
} # ]]]
# FUNCTION: .zinit-format-parameter [[[
# Creates one column text that lists global parameters that
# changed when the given plugin was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-parameter() {
    local uspl2="$1" infoc="${ZINIT[col-info]}" k

    builtin setopt localoptions extendedglob nokshglob noksharrays
    REPLY=""
    [[ "${ZINIT[PARAMETERS_PRE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PARAMETERS_POST__$uspl2]}" != *[$'! \t']* ]] && return 0

    typeset -A elem_pre elem_post
    elem_pre=( "${(z)ZINIT[PARAMETERS_PRE__$uspl2]}" )
    elem_post=( "${(z)ZINIT[PARAMETERS_POST__$uspl2]}" )

    # Find longest key and longest value
    integer longest=0 vlongest1=0 vlongest2=0
    local v1 v2
    for k in "${(k)elem_post[@]}"; do
        k="${(Q)k}"
        [[ "${#k}" -gt "$longest" ]] && longest="${#k}"

        v1="${(Q)elem_pre[$k]}"
        v2="${(Q)elem_post[$k]}"
        [[ "${#v1}" -gt "$vlongest1" ]] && vlongest1="${#v1}"
        [[ "${#v2}" -gt "$vlongest2" ]] && vlongest2="${#v2}"
    done

    # Enumerate parameters that changed. A key
    # always exists in both of the arrays
    local answer="" k
    for k in "${(k)elem_post[@]}"; do
        v1="${(Q)elem_pre[$k]}"
        v2="${(Q)elem_post[$k]}"
        k="${(Q)k}"

        k="${(r:longest+1:: :)k}"
        v1="${(l:vlongest1+1:: :)v1}"
        v2="${(r:vlongest2+1:: :)v2}"
        answer+="$k ${infoc}[$v1 -> $v2]${ZINIT[col-rst]}"$'\n'
    done

    [[ -n "$answer" ]] && REPLY="$answer"

    return 0
} # ]]]

#
# Completion functions
#

# FUNCTION: .zinit-get-completion-owner [[[
# Returns "user---plugin" string (uspl1 format) of plugin that
# owns given completion.
#
# Both :A and readlink will be used, then readlink's output if
# results differ. Readlink might not be available.
#
# :A will read the link "twice" and give the final repository
# directory, possibly without username in the uspl format;
# readlink will read the link "once"
#
# $1 - absolute path to completion file (in COMPLETIONS_DIR)
# $2 - readlink command (":" or "readlink")
.zinit-get-completion-owner() {
    setopt localoptions extendedglob nokshglob noksharrays noshwordsplit
    local cpath="$1"
    local readlink_cmd="$2"
    local in_plugin_path tmp

    # Try to go not too deep into resolving the symlink,
    # to have the name as it is in .zinit/plugins
    # :A goes deep, descends fully to origin directory
    # Readlink just reads what symlink points to
    in_plugin_path="${cpath:A}"
    tmp=$( "$readlink_cmd" "$cpath" )
    # This in effect works as: "if different, then readlink"
    [[ -n "$tmp" ]] && in_plugin_path="$tmp"

    if [[ "$in_plugin_path" != "$cpath" && -r "$in_plugin_path" ]]; then
        # Get the user---plugin part of path
        while [[ "$in_plugin_path" != ${ZINIT[PLUGINS_DIR]}/[^/]## && "$in_plugin_path" != "/" && "$in_plugin_path" != "." ]]; do
            in_plugin_path="${in_plugin_path:h}"
        done
        in_plugin_path="${in_plugin_path:t}"

        if [[ -z "$in_plugin_path" ]]; then
            in_plugin_path="${tmp:h}"
        fi
    else
        # readlink and :A have nothing
        in_plugin_path="[unknown]"
    fi

    REPLY="$in_plugin_path"
} # ]]]
# FUNCTION: .zinit-get-completion-owner-uspl2col [[[
# For shortening of code - returns colorized plugin name
# that owns given completion.
#
# $1 - absolute path to completion file (in COMPLETIONS_DIR)
# $2 - readlink command (":" or "readlink")
.zinit-get-completion-owner-uspl2col() {
    # "cpath" "readline_cmd"
    .zinit-get-completion-owner "$1" "$2"
    .zinit-any-colorify-as-uspl2 "$REPLY"
} # ]]]
# FUNCTION: .zinit-find-completions-of-plugin [[[
# Searches for completions owned by given plugin.
# Returns them in `reply' array.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-find-completions-of-plugin() {
    builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
    .zinit-any-to-user-plugin "$1" "$2"
    local user="${reply[-2]}" plugin="${reply[-1]}" uspl
    [[ "$user" = "%" ]] && uspl="${user}${plugin}" || uspl="${reply[-2]}${reply[-2]:+---}${reply[-1]//\//---}"

    reply=( "${ZINIT[PLUGINS_DIR]}/$uspl"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
} # ]]]
# FUNCTION: .zinit-check-comp-consistency [[[
# Zinit creates symlink for each installed completion.
# This function checks whether given completion (i.e.
# file like "_mkdir") is indeed a symlink. Backup file
# is a completion that is disabled - has the leading "_"
# removed.
#
# $1 - path to completion within plugin's directory
# $2 - path to backup file within plugin's directory
.zinit-check-comp-consistency() {
    local cfile="$1" bkpfile="$2"
    integer error="$3"

    # bkpfile must be a symlink
    if [[ -e "$bkpfile" && ! -L "$bkpfile" ]]; then
        builtin print "${ZINIT[col-error]}Warning: completion's backup file \`${bkpfile:t}' isn't a symlink${ZINIT[col-rst]}"
        error=1
    fi

    # cfile must be a symlink
    if [[ -e "$cfile" && ! -L "$cfile" ]]; then
        builtin print "${ZINIT[col-error]}Warning: completion file \`${cfile:t}' isn't a symlink${ZINIT[col-rst]}"
        error=1
    fi

    # Tell user that he can manually modify but should do it right
    (( error )) && builtin print "${ZINIT[col-error]}Manual edit of ${ZINIT[COMPLETIONS_DIR]} occured?${ZINIT[col-rst]}"
} # ]]]
# FUNCTION: .zinit-check-which-completions-are-installed [[[
# For each argument that each should be a path to completion
# within a plugin's dir, it checks whether that completion
# is installed - returns 0 or 1 on corresponding positions
# in reply.
#
# $1, ... - path to completion within plugin's directory
.zinit-check-which-completions-are-installed() {
    local i cfile bkpfile
    reply=( )
    for i in "$@"; do
        cfile="${i:t}"
        bkpfile="${cfile#_}"

        if [[ -e "${ZINIT[COMPLETIONS_DIR]}"/"$cfile" || -e "${ZINIT[COMPLETIONS_DIR]}"/"$bkpfile" ]]; then
            reply+=( "1" )
        else
            reply+=( "0" )
        fi
    done
} # ]]]
# FUNCTION: .zinit-check-which-completions-are-enabled [[[
# For each argument that each should be a path to completion
# within a plugin's dir, it checks whether that completion
# is disabled - returns 0 or 1 on corresponding positions
# in reply.
#
# Uninstalled completions will be reported as "0"
# - i.e. disabled
#
# $1, ... - path to completion within plugin's directory
.zinit-check-which-completions-are-enabled() {
    local i cfile
    reply=( )
    for i in "$@"; do
        cfile="${i:t}"

        if [[ -e "${ZINIT[COMPLETIONS_DIR]}"/"$cfile" ]]; then
            reply+=( "1" )
        else
            reply+=( "0" )
        fi
    done
} # ]]]
# FUNCTION: .zinit-uninstall-completions [[[
# Removes all completions of given plugin from Zshell (i.e. from FPATH).
# The FPATH is typically `~/.zinit/completions/'.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-uninstall-completions() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops

    typeset -a completions symlinked backup_comps
    local c cfile bkpfile
    integer action global_action=0

    .zinit-get-path "$1" "$2"
    [[ -e $REPLY ]] && {
        completions=( $REPLY/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
    } || {
        builtin print "No completions found for \`$1${${1:#(%|/)*}:+${2:+/}}$2'"
        return 1
    }

    symlinked=( ${ZINIT[COMPLETIONS_DIR]}/_[^_.]*~*.zwc )
    backup_comps=( ${ZINIT[COMPLETIONS_DIR]}/[^_.]*~*.zwc )

    (( ${+functions[.zinit-forget-completion]} )) || builtin source ${ZINIT[BIN_DIR]}"/zinit-install.zsh"

    # Delete completions if they are really there, either
    # as completions (_fname) or backups (fname)
    for c in ${completions[@]}; do
        action=0
        cfile=${c:t}
        bkpfile=${cfile#_}

        # Remove symlink to completion
        if [[ -n ${symlinked[(r)*/$cfile]} ]]; then
            command rm -f ${ZINIT[COMPLETIONS_DIR]}/$cfile
            action=1
        fi

        # Remove backup symlink (created by cdisable)
        if [[ -n ${backup_comps[(r)*/$bkpfile]} ]]; then
            command rm -f ${ZINIT[COMPLETIONS_DIR]}/$bkpfile
            action=1
        fi

        if (( action )); then
            +zi-log "{info}Uninstalling completion \`{file}$cfile{info}'{…}{rst}"
            # Make compinit notice the change
            .zinit-forget-completion "$cfile"
            (( global_action ++ ))
        else
            +zi-log "{info}Completion \`{file}$cfile{info}' not installed.{rst}"
        fi
    done

    if (( global_action > 0 )); then
        +zi-log "{info}Uninstalled {num}$global_action{info} completions.{rst}"
    fi

    .zinit-compinit >/dev/null
} # ]]]

#
# User-exposed functions
#

# FUNCTION: .zinit-pager [[[
# BusyBox less lacks the -X and -i options, so it can use more
.zinit-pager() {
    setopt LOCAL_OPTIONS EQUALS

    # Check if a non-interactive mode has been requested, either via a flag or a global setting.
    if (( OPTS[opt_-n,--no-pager] )) || [[ ${ZINIT[NO_PAGER]} = (1|true|on|yes) ]]; then
        # NON-INTERACTIVE MODE
        local max_lines=${ZINIT[NO_PAGER_MAX_LINES]}

        # Check if a line limit is explicitly set and is a valid non-negative integer.
        if [[ $max_lines =~ ^[0-9]+$ ]]; then
            if (( max_lines > 0 )); then
                # A positive number means limit the output to that many lines.
                head -n "$max_lines"
            else
                # A value of 0 means suppress all output from the pager completely.
                # `cat > /dev/null` is the most robust way to achieve this.
                cat > /dev/null
            fi
        else
            # No valid line limit is set, so show the full output without interaction.
            cat
        fi
        return 0
    else
        # INTERACTIVE MODE (Original Behavior)
        # Fall back to the default interactive pager if no non-interactive mode is set.
        if [[ ${${:-=less}:A:t} = busybox* ]] {
            more 2>/dev/null
            (( ${+commands[more]} ))
        } else {
            less -FRXi 2>/dev/null
            (( ${+commands[less]} ))
        }
        (( $? )) && cat
        return 0
    fi
} # ]]]

# FUNCTION: .zinit-build-module [[[
# Performs ./configure && make on the module and displays information
# how to load the module in .zshrc.
.zinit-build-module() {
    setopt localoptions localtraps
    trap 'return 1' INT TERM
    if command git -C "${ZINIT[MODULE_DIR]}" rev-parse 2>/dev/null; then
        command git -C "${ZINIT[MODULE_DIR]}" clean -d -f -f
        command git -C "${ZINIT[MODULE_DIR]}" reset --hard HEAD
        command git -C "${ZINIT[MODULE_DIR]}" pull
    else
        command git clone "https://github.com/zdharma-continuum/zinit-module.git" "${ZINIT[MODULE_DIR]}" || {
            builtin print "${ZINIT[col-error]}Failed to clone module repo${ZINIT[col-rst]}"
            return 1
        }
    fi
    ( builtin cd -q "${ZINIT[MODULE_DIR]}"
      +zi-log "{pname}== Building module zdharma-continuum/zinit-module, running: make clean, then ./configure and then make =={rst}"
      +zi-log "{pname}== The module sources are located at: "${ZINIT[MODULE_DIR]}" =={rst}"
      if [[ -f Makefile ]] {
          if [[ "$1" = "--clean" ]] {
              noglob +zi-log {p}-- make distclean --{rst}
              make distclean
              ((1))
          } else {
              noglob +zi-log {p}-- make clean --{rst}
              make clean
          }
      }
      noglob +zi-log  {p}-- ./configure --{rst}
      CPPFLAGS=-I/usr/local/include CFLAGS="-g -Wall -O3" LDFLAGS=-L/usr/local/lib ./configure --disable-gdbm --without-tcsetpgrp && {
          noglob +zi-log {p}-- make --{rst}
          if { make } {
            [[ -f Src/zdharma_continuum/zinit.so ]] && cp -vf Src/zdharma_continuum/zinit.{so,bundle}
            noglob +zi-log "{info}Module has been built correctly.{rst}"
            .zinit-module info
          } else {
              noglob +zi-log  "{error}Module didn't build.{rst} "
              .zinit-module info --link
          }
      }
      builtin print $EPOCHSECONDS >! "${ZINIT[MAN_DIR]}/COMPILED_AT"
    )
} # ]]]
# FUNCTION: .zinit-module [[[
# Function that has sub-commands passed as long-options (with two dashes, --).
# It's an attempt to plugin only this one function into `zinit' function
# defined in zinit.zsh, to not make this file longer than it's needed.
.zinit-module() {
    if [[ "$1" = "build" ]]; then
        .zinit-build-module "${@[2,-1]}"
    elif [[ "$1" = "info" ]]; then
        if [[ "$2" = "--link" ]]; then
              builtin print -r "You can copy the error messages and submit"
              builtin print -r "error-report at: https://github.com/zdharma-continuum/zinit-module/issues"
        else
            builtin print -r "To load the module, add following 2 lines to .zshrc, at top:"
            builtin print -r "    module_path+=( \"${ZINIT[MODULE_DIR]}/Src\" )"
            builtin print -r "    zmodload zdharma_continuum/zinit"
            builtin print -r ""
            builtin print -r "After loading, use command \`zpmod' to communicate with the module."
            builtin print -r "See \`zpmod -h' for more information."
        fi
    elif [[ "$1" = (help|usage) ]]; then
        builtin print -r "Usage: zinit module {build|info|help} [options]"
        builtin print -r "       zinit module build [--clean]"
        builtin print -r "       zinit module info [--link]"
        builtin print -r ""
        builtin print -r "To start using the zinit Zsh module run: \`zinit module build'"
        builtin print -r "and follow the instructions. Option --clean causes \`make distclean'"
        builtin print -r "to be run. To display the instructions on loading the module, run:"
... truncated; 2,816 more lines
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/zinit/zinit-autoload.zsh — 3,616 LOC
#!/usr/bin/env zsh
#
# zdharma-continuum/zinit/zinit-autoload.zsh
# Copyright (c) 2016-2021 Sebastian Gniazdowski
# Copyright (c) 2021-2023 zdharma-continuum
# Homepage: https://github.com/zdharma-continuum/zinit
# License: MIT License
#

builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { builtin print -P "${ZINIT[col-error]}ERROR:%f%b Couldn't find ${ZINIT[col-obj]}zinit-side.zsh%f%b."; return 1; }

ZINIT[EXTENDED_GLOB]=""

#
# Backend, low level functions
#

# FUNCTION: .zinit-unregister-plugin [[[
# Removes the plugin from ZINIT_REGISTERED_PLUGINS array and from the
# zsh_loaded_plugins array (managed according to the plugin standard)
.zinit-unregister-plugin() {
    .zinit-any-to-user-plugin "$1" "$2"
    local uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" \
        teleid="$3"

    # If not found, the index will be length+1
    ZINIT_REGISTERED_PLUGINS[${ZINIT_REGISTERED_PLUGINS[(i)$uspl2]}]=()
    # Support Zsh plugin standard
    zsh_loaded_plugins[${zsh_loaded_plugins[(i)$teleid]}]=()
    ZINIT[STATES__$uspl2]="0"
} # ]]]
# FUNCTION: .zinit-diff-functions-compute [[[
# Computes FUNCTIONS that holds new functions added by plugin.
# Uses data gathered earlier by .zinit-diff-functions().
#
# $1 - user/plugin
.zinit-diff-functions-compute() {
    local uspl2="$1"

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces

    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[FUNCTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[FUNCTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A func
    local i

    # This includes new functions. Quoting is kept (i.e. no i=${(Q)i})
    for i in "${(z)ZINIT[FUNCTIONS_AFTER__$uspl2]}"; do
        func[$i]=1
    done

    # Remove duplicated entries, i.e. existing before. Quoting is kept
    for i in "${(z)ZINIT[FUNCTIONS_BEFORE__$uspl2]}"; do
        # if would do unset, then: func[opp+a\[]: invalid parameter name
        func[$i]=0
    done

    # Store the functions, associating them with plugin ($uspl2)
    ZINIT[FUNCTIONS__$uspl2]=""
    for i in "${(onk)func[@]}"; do
        [[ "${func[$i]}" = "1" ]] && ZINIT[FUNCTIONS__$uspl2]+="$i "
    done

    return 0
} # ]]]
# FUNCTION: .zinit-diff-options-compute [[[
# Computes OPTIONS that holds options changed by plugin.
# Uses data gathered earlier by .zinit-diff-options().
#
# $1 - user/plugin
.zinit-diff-options-compute() {
    local uspl2="$1"

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[OPTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[OPTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A opts_before opts_after opts
    opts_before=( "${(z)ZINIT[OPTIONS_BEFORE__$uspl2]}" )
    opts_after=( "${(z)ZINIT[OPTIONS_AFTER__$uspl2]}" )
    opts=( )

    # Iterate through first array (keys the same
    # on both of them though) and test for a change
    local key
    for key in "${(k)opts_before[@]}"; do
        if [[ "${opts_before[$key]}" != "${opts_after[$key]}" ]]; then
            opts[$key]="${opts_before[$key]}"
        fi
    done

    # Serialize for reporting
    local IFS=" "
    ZINIT[OPTIONS__$uspl2]="${(kv)opts[@]}"
    return 0
} # ]]]
# FUNCTION: .zinit-diff-env-compute [[[
# Computes ZINIT_PATH, ZINIT_FPATH that hold (f)path components
# added by plugin. Uses data gathered earlier by .zinit-diff-env().
#
# $1 - user/plugin
.zinit-diff-env-compute() {
    local uspl2="$1"
    typeset -a tmp

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[PATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
    [[ "${ZINIT[FPATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[FPATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A path_state fpath_state
    local i

    #
    # PATH processing
    #

    # This includes new path elements
    for i in "${(z)ZINIT[PATH_AFTER__$uspl2]}"; do
        path_state[${(Q)i}]=1
    done

    # Remove duplicated entries, i.e. existing before
    for i in "${(z)ZINIT[PATH_BEFORE__$uspl2]}"; do
        unset "path_state[${(Q)i}]"
    done

    # Store the path elements, associating them with plugin ($uspl2)
    ZINIT[PATH__$uspl2]=""
    for i in "${(onk)path_state[@]}"; do
        ZINIT[PATH__$uspl2]+="${(q)i} "
    done

    #
    # FPATH processing
    #

    # This includes new path elements
    for i in "${(z)ZINIT[FPATH_AFTER__$uspl2]}"; do
        fpath_state[${(Q)i}]=1
    done

    # Remove duplicated entries, i.e. existing before
    for i in "${(z)ZINIT[FPATH_BEFORE__$uspl2]}"; do
        unset "fpath_state[${(Q)i}]"
    done

    # Store the path elements, associating them with plugin ($uspl2)
    ZINIT[FPATH__$uspl2]=""
    for i in "${(onk)fpath_state[@]}"; do
        ZINIT[FPATH__$uspl2]+="${(q)i} "
    done

    return 0
} # ]]]
# FUNCTION: .zinit-diff-parameter-compute [[[
# Computes ZINIT_PARAMETERS_PRE, ZINIT_PARAMETERS_POST that hold
# parameters created or changed (their type) by plugin. Uses
# data gathered earlier by .zinit-diff-parameter().
#
# $1 - user/plugin
.zinit-diff-parameter-compute() {
    local uspl2="$1"
    typeset -a tmp

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[PARAMETERS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PARAMETERS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    # Un-concatenated parameters from moment of diff start and of diff end
    typeset -A params_before params_after
    params_before=( "${(z)ZINIT[PARAMETERS_BEFORE__$uspl2]}" )
    params_after=( "${(z)ZINIT[PARAMETERS_AFTER__$uspl2]}" )

    # The parameters that changed, with save of what
    # parameter was when diff started or when diff ended
    typeset -A params_pre params_post
    params_pre=( )
    params_post=( )

    # Iterate through all existing keys, before or after diff,
    # i.e. after all variables that were somehow live across
    # the diffing process
    local key
    typeset -aU keys
    keys=( "${(k)params_after[@]}" );
    keys=( "${keys[@]}" "${(k)params_before[@]}" );
    for key in "${keys[@]}"; do
        key="${(Q)key}"
        [[ "${params_after[$key]}" = *local* ]] && continue
        if [[ "${params_after[$key]}" != "${params_before[$key]}" ]]; then
            # Empty for a new param, a type otherwise
            [[ -z "${params_before[$key]}" ]] && params_before[$key]="\"\""
            params_pre[$key]="${params_before[$key]}"

            # Current type, can also be empty, when plugin
            # unsets a parameter
            [[ -z "${params_after[$key]}" ]] && params_after[$key]="\"\""
            params_post[$key]="${params_after[$key]}"
        fi
    done

    # Serialize for reporting
    ZINIT[PARAMETERS_PRE__$uspl2]="${(j: :)${(qkv)params_pre[@]}}"
    ZINIT[PARAMETERS_POST__$uspl2]="${(j: :)${(qkv)params_post[@]}}"

    return 0
} # ]]]
# FUNCTION: .zinit-any-to-uspl2 [[[
# Converts given plugin-spec to format that's used in keys for hash tables.
# So basically, creates string "user/plugin" (this format is called: uspl2).
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-any-to-uspl2() {
    .zinit-any-to-user-plugin "$1" "$2"
    [[ "${reply[-2]}" = "%" ]] && REPLY="${reply[-2]}${reply[-1]}" || REPLY="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]//---//}"
} # ]]]
# FUNCTION: .zinit-save-set-extendedglob [[[
# Enables extendedglob-option first saving if it was already
# enabled, for restoration of this state later.
.zinit-save-set-extendedglob() {
    [[ -o "extendedglob" ]] && ZINIT[EXTENDED_GLOB]="1" || ZINIT[EXTENDED_GLOB]="0"
    builtin setopt extendedglob
} # ]]]
# FUNCTION: .zinit-restore-extendedglob [[[
# Restores extendedglob-option from state saved earlier.
.zinit-restore-extendedglob() {
    [[ "${ZINIT[EXTENDED_GLOB]}" = "0" ]] && builtin unsetopt extendedglob || builtin setopt extendedglob
} # ]]]
# FUNCTION: .zinit-prepare-readlink [[[
# Prepares readlink command, used for establishing completion's owner.
#
# $REPLY = ":" or "readlink"
.zinit-prepare-readlink() {
    REPLY=":"
    if type readlink 2>/dev/null 1>&2; then
        REPLY="readlink"
    fi
} # ]]]
# FUNCTION: .zinit-clear-report-for [[[
# Clears all report data for given user/plugin. This is
# done by resetting all related global ZINIT_* hashes.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-clear-report-for() {
    .zinit-any-to-uspl2 "$1" "$2"

    # Shadowing
    ZINIT_REPORTS[$REPLY]=""
    ZINIT[BINDKEYS__$REPLY]=""
    ZINIT[ZSTYLES__$REPLY]=""
    ZINIT[ALIASES__$REPLY]=""
    ZINIT[WIDGETS_SAVED__$REPLY]=""
    ZINIT[WIDGETS_DELETE__$REPLY]=""

    # Function diffing
    ZINIT[FUNCTIONS__$REPLY]=""
    ZINIT[FUNCTIONS_BEFORE__$REPLY]=""
    ZINIT[FUNCTIONS_AFTER__$REPLY]=""

    # Option diffing
    ZINIT[OPTIONS__$REPLY]=""
    ZINIT[OPTIONS_BEFORE__$REPLY]=""
    ZINIT[OPTIONS_AFTER__$REPLY]=""

    # Environment diffing
    ZINIT[PATH__$REPLY]=""
    ZINIT[PATH_BEFORE__$REPLY]=""
    ZINIT[PATH_AFTER__$REPLY]=""
    ZINIT[FPATH__$REPLY]=""
    ZINIT[FPATH_BEFORE__$REPLY]=""
    ZINIT[FPATH_AFTER__$REPLY]=""

    # Parameter diffing
    ZINIT[PARAMETERS_PRE__$REPLY]=""
    ZINIT[PARAMETERS_POST__$REPLY]=""
    ZINIT[PARAMETERS_BEFORE__$REPLY]=""
    ZINIT[PARAMETERS_AFTER__$REPLY]=""
} # ]]]
# FUNCTION: .zinit-exists-message [[[
# Checks if plugin is loaded. Testable. Also outputs error
# message if plugin is not loaded.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-exists-message() {
    .zinit-any-to-uspl2 "$1" "$2"
    if [[ -z "${ZINIT_REGISTERED_PLUGINS[(r)$REPLY]}" ]]; then
        .zinit-any-colorify-as-uspl2 "$1" "$2"
        builtin print "${ZINIT[col-error]}No such plugin${ZINIT[col-rst]} $REPLY"
        return 1
    fi
    return 0
} # ]]]
# FUNCTION: .zinit-at-eval [[[
.zinit-at-eval() {
    local atclone="$2" atpull="$1"
    integer retval
    @zinit-substitute atclone atpull
    [[ $atpull = "%atclone" ]] && { eval "$atclone"; retval=$?; } || { eval "$atpull"; retval=$?; }
    return $retval
} # ]]]

#
# Format functions
#

# FUNCTION: .zinit-format-functions [[[
# Creates a one or two columns text with functions created
# by given plugin.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-functions() {
    local uspl2="$1"

    typeset -a func
    func=( "${(z)ZINIT[FUNCTIONS__$uspl2]}" )

    # Get length of longest left-right string pair,
    # and length of longest left string
    integer longest=0 longest_left=0 cur_left_len=0 count=1
    local f
    for f in "${(on)func[@]}"; do
        [[ -z "${#f}" ]] && continue
        f="${(Q)f}"

        # Compute for elements in left column,
        # ones that will be paded with spaces
        if (( count ++ % 2 != 0 )); then
            [[ "${#f}" -gt "$longest_left" ]] && longest_left="${#f}"
            cur_left_len="${#f}"
        else
            cur_left_len+="${#f}"
            cur_left_len+=1 # For separating space
            [[ "$cur_left_len" -gt "$longest" ]] && longest="$cur_left_len"
        fi
    done

    # Output in one or two columns
    local answer=""
    count=1
    for f in "${(on)func[@]}"; do
        [[ -z "$f" ]] && continue
        f="${(Q)f}"

        if (( COLUMNS >= longest )); then
            if (( count ++ % 2 != 0 )); then
                answer+="${(r:longest_left+1:: :)f}"
            else
                answer+="$f"$'\n'
            fi
        else
            answer+="$f"$'\n'
        fi
    done
    REPLY="$answer"
    # == 0 is: next element would have newline (postfix addition in "count ++")
    (( COLUMNS >= longest && count % 2 == 0 )) && REPLY="$REPLY"$'\n'
} # ]]]
# FUNCTION: .zinit-format-options [[[
# Creates one-column text about options that changed when
# plugin "$1" was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-options() {
    local uspl2="$1"

    REPLY=""

    # Paranoid, don't want bad key/value pair error
    integer empty=0
    .zinit-save-set-extendedglob
    [[ "${ZINIT[OPTIONS__$uspl2]}" != *[$'! \t']* ]] && empty=1
    .zinit-restore-extendedglob
    (( empty )) && return 0

    typeset -A opts
    opts=( "${(z)ZINIT[OPTIONS__$uspl2]}" )

    # Get length of longest option
    integer longest=0
    local k
    for k in "${(kon)opts[@]}"; do
        [[ "${#k}" -gt "$longest" ]] && longest="${#k}"
    done

    # Output in one column
    local txt
    for k in "${(kon)opts[@]}"; do
        [[ "${opts[$k]}" = "on" ]] && txt="was unset" || txt="was set"
        REPLY+="${(r:longest+1:: :)k}$txt"$'\n'
    done
} # ]]]
# FUNCTION: .zinit-format-env [[[
# Creates one-column text about FPATH or PATH elements
# added when given plugin was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
# $2 - if 1, then examine PATH, if 2, then examine FPATH
.zinit-format-env() {
    local uspl2="$1" which="$2"

    # Format PATH?
    if [[ "$which" = "1" ]]; then
        typeset -a elem
        elem=( "${(z@)ZINIT[PATH__$uspl2]}" )
    elif [[ "$which" = "2" ]]; then
        typeset -a elem
        elem=( "${(z@)ZINIT[FPATH__$uspl2]}" )
    fi

    # Enumerate elements added
    local answer="" e
    for e in "${elem[@]}"; do
        [[ -z "$e" ]] && continue
        e="${(Q)e}"
        answer+="$e"$'\n'
    done

    [[ -n "$answer" ]] && REPLY="$answer"
} # ]]]
# FUNCTION: .zinit-format-parameter [[[
# Creates one column text that lists global parameters that
# changed when the given plugin was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-parameter() {
    local uspl2="$1" infoc="${ZINIT[col-info]}" k

    builtin setopt localoptions extendedglob nokshglob noksharrays
    REPLY=""
    [[ "${ZINIT[PARAMETERS_PRE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PARAMETERS_POST__$uspl2]}" != *[$'! \t']* ]] && return 0

    typeset -A elem_pre elem_post
    elem_pre=( "${(z)ZINIT[PARAMETERS_PRE__$uspl2]}" )
    elem_post=( "${(z)ZINIT[PARAMETERS_POST__$uspl2]}" )

    # Find longest key and longest value
    integer longest=0 vlongest1=0 vlongest2=0
    local v1 v2
    for k in "${(k)elem_post[@]}"; do
        k="${(Q)k}"
        [[ "${#k}" -gt "$longest" ]] && longest="${#k}"

        v1="${(Q)elem_pre[$k]}"
        v2="${(Q)elem_post[$k]}"
        [[ "${#v1}" -gt "$vlongest1" ]] && vlongest1="${#v1}"
        [[ "${#v2}" -gt "$vlongest2" ]] && vlongest2="${#v2}"
    done

    # Enumerate parameters that changed. A key
    # always exists in both of the arrays
    local answer="" k
    for k in "${(k)elem_post[@]}"; do
        v1="${(Q)elem_pre[$k]}"
        v2="${(Q)elem_post[$k]}"
        k="${(Q)k}"

        k="${(r:longest+1:: :)k}"
        v1="${(l:vlongest1+1:: :)v1}"
        v2="${(r:vlongest2+1:: :)v2}"
        answer+="$k ${infoc}[$v1 -> $v2]${ZINIT[col-rst]}"$'\n'
    done

    [[ -n "$answer" ]] && REPLY="$answer"

    return 0
} # ]]]

#
# Completion functions
#

# FUNCTION: .zinit-get-completion-owner [[[
# Returns "user---plugin" string (uspl1 format) of plugin that
# owns given completion.
#
# Both :A and readlink will be used, then readlink's output if
# results differ. Readlink might not be available.
#
# :A will read the link "twice" and give the final repository
# directory, possibly without username in the uspl format;
# readlink will read the link "once"
#
# $1 - absolute path to completion file (in COMPLETIONS_DIR)
# $2 - readlink command (":" or "readlink")
.zinit-get-completion-owner() {
    setopt localoptions extendedglob nokshglob noksharrays noshwordsplit
    local cpath="$1"
    local readlink_cmd="$2"
    local in_plugin_path tmp

    # Try to go not too deep into resolving the symlink,
    # to have the name as it is in .zinit/plugins
    # :A goes deep, descends fully to origin directory
    # Readlink just reads what symlink points to
    in_plugin_path="${cpath:A}"
    tmp=$( "$readlink_cmd" "$cpath" )
    # This in effect works as: "if different, then readlink"
    [[ -n "$tmp" ]] && in_plugin_path="$tmp"

    if [[ "$in_plugin_path" != "$cpath" && -r "$in_plugin_path" ]]; then
        # Get the user---plugin part of path
        while [[ "$in_plugin_path" != ${ZINIT[PLUGINS_DIR]}/[^/]## && "$in_plugin_path" != "/" && "$in_plugin_path" != "." ]]; do
            in_plugin_path="${in_plugin_path:h}"
        done
        in_plugin_path="${in_plugin_path:t}"

        if [[ -z "$in_plugin_path" ]]; then
            in_plugin_path="${tmp:h}"
        fi
    else
        # readlink and :A have nothing
        in_plugin_path="[unknown]"
    fi

    REPLY="$in_plugin_path"
} # ]]]
# FUNCTION: .zinit-get-completion-owner-uspl2col [[[
# For shortening of code - returns colorized plugin name
# that owns given completion.
#
# $1 - absolute path to completion file (in COMPLETIONS_DIR)
# $2 - readlink command (":" or "readlink")
.zinit-get-completion-owner-uspl2col() {
    # "cpath" "readline_cmd"
    .zinit-get-completion-owner "$1" "$2"
    .zinit-any-colorify-as-uspl2 "$REPLY"
} # ]]]
# FUNCTION: .zinit-find-completions-of-plugin [[[
# Searches for completions owned by given plugin.
# Returns them in `reply' array.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-find-completions-of-plugin() {
    builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
    .zinit-any-to-user-plugin "$1" "$2"
    local user="${reply[-2]}" plugin="${reply[-1]}" uspl
    [[ "$user" = "%" ]] && uspl="${user}${plugin}" || uspl="${reply[-2]}${reply[-2]:+---}${reply[-1]//\//---}"

    reply=( "${ZINIT[PLUGINS_DIR]}/$uspl"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
} # ]]]
# FUNCTION: .zinit-check-comp-consistency [[[
# Zinit creates symlink for each installed completion.
# This function checks whether given completion (i.e.
# file like "_mkdir") is indeed a symlink. Backup file
# is a completion that is disabled - has the leading "_"
# removed.
#
# $1 - path to completion within plugin's directory
# $2 - path to backup file within plugin's directory
.zinit-check-comp-consistency() {
    local cfile="$1" bkpfile="$2"
    integer error="$3"

    # bkpfile must be a symlink
    if [[ -e "$bkpfile" && ! -L "$bkpfile" ]]; then
        builtin print "${ZINIT[col-error]}Warning: completion's backup file \`${bkpfile:t}' isn't a symlink${ZINIT[col-rst]}"
        error=1
    fi

    # cfile must be a symlink
    if [[ -e "$cfile" && ! -L "$cfile" ]]; then
        builtin print "${ZINIT[col-error]}Warning: completion file \`${cfile:t}' isn't a symlink${ZINIT[col-rst]}"
        error=1
    fi

    # Tell user that he can manually modify but should do it right
    (( error )) && builtin print "${ZINIT[col-error]}Manual edit of ${ZINIT[COMPLETIONS_DIR]} occured?${ZINIT[col-rst]}"
} # ]]]
# FUNCTION: .zinit-check-which-completions-are-installed [[[
# For each argument that each should be a path to completion
# within a plugin's dir, it checks whether that completion
# is installed - returns 0 or 1 on corresponding positions
# in reply.
#
# $1, ... - path to completion within plugin's directory
.zinit-check-which-completions-are-installed() {
    local i cfile bkpfile
    reply=( )
    for i in "$@"; do
        cfile="${i:t}"
        bkpfile="${cfile#_}"

        if [[ -e "${ZINIT[COMPLETIONS_DIR]}"/"$cfile" || -e "${ZINIT[COMPLETIONS_DIR]}"/"$bkpfile" ]]; then
            reply+=( "1" )
        else
            reply+=( "0" )
        fi
    done
} # ]]]
# FUNCTION: .zinit-check-which-completions-are-enabled [[[
# For each argument that each should be a path to completion
# within a plugin's dir, it checks whether that completion
# is disabled - returns 0 or 1 on corresponding positions
# in reply.
#
# Uninstalled completions will be reported as "0"
# - i.e. disabled
#
# $1, ... - path to completion within plugin's directory
.zinit-check-which-completions-are-enabled() {
    local i cfile
    reply=( )
    for i in "$@"; do
        cfile="${i:t}"

        if [[ -e "${ZINIT[COMPLETIONS_DIR]}"/"$cfile" ]]; then
            reply+=( "1" )
        else
            reply+=( "0" )
        fi
    done
} # ]]]
# FUNCTION: .zinit-uninstall-completions [[[
# Removes all completions of given plugin from Zshell (i.e. from FPATH).
# The FPATH is typically `~/.zinit/completions/'.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-uninstall-completions() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops

    typeset -a completions symlinked backup_comps
    local c cfile bkpfile
    integer action global_action=0

    .zinit-get-path "$1" "$2"
    [[ -e $REPLY ]] && {
        completions=( $REPLY/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
    } || {
        builtin print "No completions found for \`$1${${1:#(%|/)*}:+${2:+/}}$2'"
        return 1
    }

    symlinked=( ${ZINIT[COMPLETIONS_DIR]}/_[^_.]*~*.zwc )
    backup_comps=( ${ZINIT[COMPLETIONS_DIR]}/[^_.]*~*.zwc )

    (( ${+functions[.zinit-forget-completion]} )) || builtin source ${ZINIT[BIN_DIR]}"/zinit-install.zsh"

    # Delete completions if they are really there, either
    # as completions (_fname) or backups (fname)
    for c in ${completions[@]}; do
        action=0
        cfile=${c:t}
        bkpfile=${cfile#_}

        # Remove symlink to completion
        if [[ -n ${symlinked[(r)*/$cfile]} ]]; then
            command rm -f ${ZINIT[COMPLETIONS_DIR]}/$cfile
            action=1
        fi

        # Remove backup symlink (created by cdisable)
        if [[ -n ${backup_comps[(r)*/$bkpfile]} ]]; then
            command rm -f ${ZINIT[COMPLETIONS_DIR]}/$bkpfile
            action=1
        fi

        if (( action )); then
            +zi-log "{info}Uninstalling completion \`{file}$cfile{info}'{…}{rst}"
            # Make compinit notice the change
            .zinit-forget-completion "$cfile"
            (( global_action ++ ))
        else
            +zi-log "{info}Completion \`{file}$cfile{info}' not installed.{rst}"
        fi
    done

    if (( global_action > 0 )); then
        +zi-log "{info}Uninstalled {num}$global_action{info} completions.{rst}"
    fi

    .zinit-compinit >/dev/null
} # ]]]

#
# User-exposed functions
#

# FUNCTION: .zinit-pager [[[
# BusyBox less lacks the -X and -i options, so it can use more
.zinit-pager() {
    setopt LOCAL_OPTIONS EQUALS

    # Check if a non-interactive mode has been requested, either via a flag or a global setting.
    if (( OPTS[opt_-n,--no-pager] )) || [[ ${ZINIT[NO_PAGER]} = (1|true|on|yes) ]]; then
        # NON-INTERACTIVE MODE
        local max_lines=${ZINIT[NO_PAGER_MAX_LINES]}

        # Check if a line limit is explicitly set and is a valid non-negative integer.
        if [[ $max_lines =~ ^[0-9]+$ ]]; then
            if (( max_lines > 0 )); then
                # A positive number means limit the output to that many lines.
                head -n "$max_lines"
            else
                # A value of 0 means suppress all output from the pager completely.
                # `cat > /dev/null` is the most robust way to achieve this.
                cat > /dev/null
            fi
        else
            # No valid line limit is set, so show the full output without interaction.
            cat
        fi
        return 0
    else
        # INTERACTIVE MODE (Original Behavior)
        # Fall back to the default interactive pager if no non-interactive mode is set.
        if [[ ${${:-=less}:A:t} = busybox* ]] {
            more 2>/dev/null
            (( ${+commands[more]} ))
        } else {
            less -FRXi 2>/dev/null
            (( ${+commands[less]} ))
        }
        (( $? )) && cat
        return 0
    fi
} # ]]]

# FUNCTION: .zinit-build-module [[[
# Performs ./configure && make on the module and displays information
# how to load the module in .zshrc.
.zinit-build-module() {
    setopt localoptions localtraps
    trap 'return 1' INT TERM
    if command git -C "${ZINIT[MODULE_DIR]}" rev-parse 2>/dev/null; then
        command git -C "${ZINIT[MODULE_DIR]}" clean -d -f -f
        command git -C "${ZINIT[MODULE_DIR]}" reset --hard HEAD
        command git -C "${ZINIT[MODULE_DIR]}" pull
    else
        command git clone "https://github.com/zdharma-continuum/zinit-module.git" "${ZINIT[MODULE_DIR]}" || {
            builtin print "${ZINIT[col-error]}Failed to clone module repo${ZINIT[col-rst]}"
            return 1
        }
    fi
    ( builtin cd -q "${ZINIT[MODULE_DIR]}"
      +zi-log "{pname}== Building module zdharma-continuum/zinit-module, running: make clean, then ./configure and then make =={rst}"
      +zi-log "{pname}== The module sources are located at: "${ZINIT[MODULE_DIR]}" =={rst}"
      if [[ -f Makefile ]] {
          if [[ "$1" = "--clean" ]] {
              noglob +zi-log {p}-- make distclean --{rst}
              make distclean
              ((1))
          } else {
              noglob +zi-log {p}-- make clean --{rst}
              make clean
          }
      }
      noglob +zi-log  {p}-- ./configure --{rst}
      CPPFLAGS=-I/usr/local/include CFLAGS="-g -Wall -O3" LDFLAGS=-L/usr/local/lib ./configure --disable-gdbm --without-tcsetpgrp && {
          noglob +zi-log {p}-- make --{rst}
          if { make } {
            [[ -f Src/zdharma_continuum/zinit.so ]] && cp -vf Src/zdharma_continuum/zinit.{so,bundle}
            noglob +zi-log "{info}Module has been built correctly.{rst}"
            .zinit-module info
          } else {
              noglob +zi-log  "{error}Module didn't build.{rst} "
              .zinit-module info --link
          }
      }
      builtin print $EPOCHSECONDS >! "${ZINIT[MAN_DIR]}/COMPILED_AT"
    )
} # ]]]
# FUNCTION: .zinit-module [[[
# Function that has sub-commands passed as long-options (with two dashes, --).
# It's an attempt to plugin only this one function into `zinit' function
# defined in zinit.zsh, to not make this file longer than it's needed.
.zinit-module() {
    if [[ "$1" = "build" ]]; then
        .zinit-build-module "${@[2,-1]}"
    elif [[ "$1" = "info" ]]; then
        if [[ "$2" = "--link" ]]; then
              builtin print -r "You can copy the error messages and submit"
              builtin print -r "error-report at: https://github.com/zdharma-continuum/zinit-module/issues"
        else
            builtin print -r "To load the module, add following 2 lines to .zshrc, at top:"
            builtin print -r "    module_path+=( \"${ZINIT[MODULE_DIR]}/Src\" )"
            builtin print -r "    zmodload zdharma_continuum/zinit"
            builtin print -r ""
            builtin print -r "After loading, use command \`zpmod' to communicate with the module."
            builtin print -r "See \`zpmod -h' for more information."
        fi
    elif [[ "$1" = (help|usage) ]]; then
        builtin print -r "Usage: zinit module {build|info|help} [options]"
        builtin print -r "       zinit module build [--clean]"
        builtin print -r "       zinit module info [--link]"
        builtin print -r ""
        builtin print -r "To start using the zinit Zsh module run: \`zinit module build'"
        builtin print -r "and follow the instructions. Option --clean causes \`make distclean'"
        builtin print -r "to be run. To display the instructions on loading the module, run:"
... truncated; 2,816 more lines
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/zinit/zinit-autoload.zsh — 3,616 LOC
#!/usr/bin/env zsh
#
# zdharma-continuum/zinit/zinit-autoload.zsh
# Copyright (c) 2016-2021 Sebastian Gniazdowski
# Copyright (c) 2021-2023 zdharma-continuum
# Homepage: https://github.com/zdharma-continuum/zinit
# License: MIT License
#

builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { builtin print -P "${ZINIT[col-error]}ERROR:%f%b Couldn't find ${ZINIT[col-obj]}zinit-side.zsh%f%b."; return 1; }

ZINIT[EXTENDED_GLOB]=""

#
# Backend, low level functions
#

# FUNCTION: .zinit-unregister-plugin [[[
# Removes the plugin from ZINIT_REGISTERED_PLUGINS array and from the
# zsh_loaded_plugins array (managed according to the plugin standard)
.zinit-unregister-plugin() {
    .zinit-any-to-user-plugin "$1" "$2"
    local uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" \
        teleid="$3"

    # If not found, the index will be length+1
    ZINIT_REGISTERED_PLUGINS[${ZINIT_REGISTERED_PLUGINS[(i)$uspl2]}]=()
    # Support Zsh plugin standard
    zsh_loaded_plugins[${zsh_loaded_plugins[(i)$teleid]}]=()
    ZINIT[STATES__$uspl2]="0"
} # ]]]
# FUNCTION: .zinit-diff-functions-compute [[[
# Computes FUNCTIONS that holds new functions added by plugin.
# Uses data gathered earlier by .zinit-diff-functions().
#
# $1 - user/plugin
.zinit-diff-functions-compute() {
    local uspl2="$1"

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces

    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[FUNCTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[FUNCTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A func
    local i

    # This includes new functions. Quoting is kept (i.e. no i=${(Q)i})
    for i in "${(z)ZINIT[FUNCTIONS_AFTER__$uspl2]}"; do
        func[$i]=1
    done

    # Remove duplicated entries, i.e. existing before. Quoting is kept
    for i in "${(z)ZINIT[FUNCTIONS_BEFORE__$uspl2]}"; do
        # if would do unset, then: func[opp+a\[]: invalid parameter name
        func[$i]=0
    done

    # Store the functions, associating them with plugin ($uspl2)
    ZINIT[FUNCTIONS__$uspl2]=""
    for i in "${(onk)func[@]}"; do
        [[ "${func[$i]}" = "1" ]] && ZINIT[FUNCTIONS__$uspl2]+="$i "
    done

    return 0
} # ]]]
# FUNCTION: .zinit-diff-options-compute [[[
# Computes OPTIONS that holds options changed by plugin.
# Uses data gathered earlier by .zinit-diff-options().
#
# $1 - user/plugin
.zinit-diff-options-compute() {
    local uspl2="$1"

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[OPTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[OPTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A opts_before opts_after opts
    opts_before=( "${(z)ZINIT[OPTIONS_BEFORE__$uspl2]}" )
    opts_after=( "${(z)ZINIT[OPTIONS_AFTER__$uspl2]}" )
    opts=( )

    # Iterate through first array (keys the same
    # on both of them though) and test for a change
    local key
    for key in "${(k)opts_before[@]}"; do
        if [[ "${opts_before[$key]}" != "${opts_after[$key]}" ]]; then
            opts[$key]="${opts_before[$key]}"
        fi
    done

    # Serialize for reporting
    local IFS=" "
    ZINIT[OPTIONS__$uspl2]="${(kv)opts[@]}"
    return 0
} # ]]]
# FUNCTION: .zinit-diff-env-compute [[[
# Computes ZINIT_PATH, ZINIT_FPATH that hold (f)path components
# added by plugin. Uses data gathered earlier by .zinit-diff-env().
#
# $1 - user/plugin
.zinit-diff-env-compute() {
    local uspl2="$1"
    typeset -a tmp

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[PATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
    [[ "${ZINIT[FPATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[FPATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A path_state fpath_state
    local i

    #
    # PATH processing
    #

    # This includes new path elements
    for i in "${(z)ZINIT[PATH_AFTER__$uspl2]}"; do
        path_state[${(Q)i}]=1
    done

    # Remove duplicated entries, i.e. existing before
    for i in "${(z)ZINIT[PATH_BEFORE__$uspl2]}"; do
        unset "path_state[${(Q)i}]"
    done

    # Store the path elements, associating them with plugin ($uspl2)
    ZINIT[PATH__$uspl2]=""
    for i in "${(onk)path_state[@]}"; do
        ZINIT[PATH__$uspl2]+="${(q)i} "
    done

    #
    # FPATH processing
    #

    # This includes new path elements
    for i in "${(z)ZINIT[FPATH_AFTER__$uspl2]}"; do
        fpath_state[${(Q)i}]=1
    done

    # Remove duplicated entries, i.e. existing before
    for i in "${(z)ZINIT[FPATH_BEFORE__$uspl2]}"; do
        unset "fpath_state[${(Q)i}]"
    done

    # Store the path elements, associating them with plugin ($uspl2)
    ZINIT[FPATH__$uspl2]=""
    for i in "${(onk)fpath_state[@]}"; do
        ZINIT[FPATH__$uspl2]+="${(q)i} "
    done

    return 0
} # ]]]
# FUNCTION: .zinit-diff-parameter-compute [[[
# Computes ZINIT_PARAMETERS_PRE, ZINIT_PARAMETERS_POST that hold
# parameters created or changed (their type) by plugin. Uses
# data gathered earlier by .zinit-diff-parameter().
#
# $1 - user/plugin
.zinit-diff-parameter-compute() {
    local uspl2="$1"
    typeset -a tmp

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[PARAMETERS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PARAMETERS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    # Un-concatenated parameters from moment of diff start and of diff end
    typeset -A params_before params_after
    params_before=( "${(z)ZINIT[PARAMETERS_BEFORE__$uspl2]}" )
    params_after=( "${(z)ZINIT[PARAMETERS_AFTER__$uspl2]}" )

    # The parameters that changed, with save of what
    # parameter was when diff started or when diff ended
    typeset -A params_pre params_post
    params_pre=( )
    params_post=( )

    # Iterate through all existing keys, before or after diff,
    # i.e. after all variables that were somehow live across
    # the diffing process
    local key
    typeset -aU keys
    keys=( "${(k)params_after[@]}" );
    keys=( "${keys[@]}" "${(k)params_before[@]}" );
    for key in "${keys[@]}"; do
        key="${(Q)key}"
        [[ "${params_after[$key]}" = *local* ]] && continue
        if [[ "${params_after[$key]}" != "${params_before[$key]}" ]]; then
            # Empty for a new param, a type otherwise
            [[ -z "${params_before[$key]}" ]] && params_before[$key]="\"\""
            params_pre[$key]="${params_before[$key]}"

            # Current type, can also be empty, when plugin
            # unsets a parameter
            [[ -z "${params_after[$key]}" ]] && params_after[$key]="\"\""
            params_post[$key]="${params_after[$key]}"
        fi
    done

    # Serialize for reporting
    ZINIT[PARAMETERS_PRE__$uspl2]="${(j: :)${(qkv)params_pre[@]}}"
    ZINIT[PARAMETERS_POST__$uspl2]="${(j: :)${(qkv)params_post[@]}}"

    return 0
} # ]]]
# FUNCTION: .zinit-any-to-uspl2 [[[
# Converts given plugin-spec to format that's used in keys for hash tables.
# So basically, creates string "user/plugin" (this format is called: uspl2).
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-any-to-uspl2() {
    .zinit-any-to-user-plugin "$1" "$2"
    [[ "${reply[-2]}" = "%" ]] && REPLY="${reply[-2]}${reply[-1]}" || REPLY="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]//---//}"
} # ]]]
# FUNCTION: .zinit-save-set-extendedglob [[[
# Enables extendedglob-option first saving if it was already
# enabled, for restoration of this state later.
.zinit-save-set-extendedglob() {
    [[ -o "extendedglob" ]] && ZINIT[EXTENDED_GLOB]="1" || ZINIT[EXTENDED_GLOB]="0"
    builtin setopt extendedglob
} # ]]]
# FUNCTION: .zinit-restore-extendedglob [[[
# Restores extendedglob-option from state saved earlier.
.zinit-restore-extendedglob() {
    [[ "${ZINIT[EXTENDED_GLOB]}" = "0" ]] && builtin unsetopt extendedglob || builtin setopt extendedglob
} # ]]]
# FUNCTION: .zinit-prepare-readlink [[[
# Prepares readlink command, used for establishing completion's owner.
#
# $REPLY = ":" or "readlink"
.zinit-prepare-readlink() {
    REPLY=":"
    if type readlink 2>/dev/null 1>&2; then
        REPLY="readlink"
    fi
} # ]]]
# FUNCTION: .zinit-clear-report-for [[[
# Clears all report data for given user/plugin. This is
# done by resetting all related global ZINIT_* hashes.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-clear-report-for() {
    .zinit-any-to-uspl2 "$1" "$2"

    # Shadowing
    ZINIT_REPORTS[$REPLY]=""
    ZINIT[BINDKEYS__$REPLY]=""
    ZINIT[ZSTYLES__$REPLY]=""
    ZINIT[ALIASES__$REPLY]=""
    ZINIT[WIDGETS_SAVED__$REPLY]=""
    ZINIT[WIDGETS_DELETE__$REPLY]=""

    # Function diffing
    ZINIT[FUNCTIONS__$REPLY]=""
    ZINIT[FUNCTIONS_BEFORE__$REPLY]=""
    ZINIT[FUNCTIONS_AFTER__$REPLY]=""

    # Option diffing
    ZINIT[OPTIONS__$REPLY]=""
    ZINIT[OPTIONS_BEFORE__$REPLY]=""
    ZINIT[OPTIONS_AFTER__$REPLY]=""

    # Environment diffing
    ZINIT[PATH__$REPLY]=""
    ZINIT[PATH_BEFORE__$REPLY]=""
    ZINIT[PATH_AFTER__$REPLY]=""
    ZINIT[FPATH__$REPLY]=""
    ZINIT[FPATH_BEFORE__$REPLY]=""
    ZINIT[FPATH_AFTER__$REPLY]=""

    # Parameter diffing
    ZINIT[PARAMETERS_PRE__$REPLY]=""
    ZINIT[PARAMETERS_POST__$REPLY]=""
    ZINIT[PARAMETERS_BEFORE__$REPLY]=""
    ZINIT[PARAMETERS_AFTER__$REPLY]=""
} # ]]]
# FUNCTION: .zinit-exists-message [[[
# Checks if plugin is loaded. Testable. Also outputs error
# message if plugin is not loaded.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-exists-message() {
    .zinit-any-to-uspl2 "$1" "$2"
    if [[ -z "${ZINIT_REGISTERED_PLUGINS[(r)$REPLY]}" ]]; then
        .zinit-any-colorify-as-uspl2 "$1" "$2"
        builtin print "${ZINIT[col-error]}No such plugin${ZINIT[col-rst]} $REPLY"
        return 1
    fi
    return 0
} # ]]]
# FUNCTION: .zinit-at-eval [[[
.zinit-at-eval() {
    local atclone="$2" atpull="$1"
    integer retval
    @zinit-substitute atclone atpull
    [[ $atpull = "%atclone" ]] && { eval "$atclone"; retval=$?; } || { eval "$atpull"; retval=$?; }
    return $retval
} # ]]]

#
# Format functions
#

# FUNCTION: .zinit-format-functions [[[
# Creates a one or two columns text with functions created
# by given plugin.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-functions() {
    local uspl2="$1"

    typeset -a func
    func=( "${(z)ZINIT[FUNCTIONS__$uspl2]}" )

    # Get length of longest left-right string pair,
    # and length of longest left string
    integer longest=0 longest_left=0 cur_left_len=0 count=1
    local f
    for f in "${(on)func[@]}"; do
        [[ -z "${#f}" ]] && continue
        f="${(Q)f}"

        # Compute for elements in left column,
        # ones that will be paded with spaces
        if (( count ++ % 2 != 0 )); then
            [[ "${#f}" -gt "$longest_left" ]] && longest_left="${#f}"
            cur_left_len="${#f}"
        else
            cur_left_len+="${#f}"
            cur_left_len+=1 # For separating space
            [[ "$cur_left_len" -gt "$longest" ]] && longest="$cur_left_len"
        fi
    done

    # Output in one or two columns
    local answer=""
    count=1
    for f in "${(on)func[@]}"; do
        [[ -z "$f" ]] && continue
        f="${(Q)f}"

        if (( COLUMNS >= longest )); then
            if (( count ++ % 2 != 0 )); then
                answer+="${(r:longest_left+1:: :)f}"
            else
                answer+="$f"$'\n'
            fi
        else
            answer+="$f"$'\n'
        fi
    done
    REPLY="$answer"
    # == 0 is: next element would have newline (postfix addition in "count ++")
    (( COLUMNS >= longest && count % 2 == 0 )) && REPLY="$REPLY"$'\n'
} # ]]]
# FUNCTION: .zinit-format-options [[[
# Creates one-column text about options that changed when
# plugin "$1" was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-options() {
    local uspl2="$1"

    REPLY=""

    # Paranoid, don't want bad key/value pair error
    integer empty=0
    .zinit-save-set-extendedglob
    [[ "${ZINIT[OPTIONS__$uspl2]}" != *[$'! \t']* ]] && empty=1
    .zinit-restore-extendedglob
    (( empty )) && return 0

    typeset -A opts
    opts=( "${(z)ZINIT[OPTIONS__$uspl2]}" )

    # Get length of longest option
    integer longest=0
    local k
    for k in "${(kon)opts[@]}"; do
        [[ "${#k}" -gt "$longest" ]] && longest="${#k}"
    done

    # Output in one column
    local txt
    for k in "${(kon)opts[@]}"; do
        [[ "${opts[$k]}" = "on" ]] && txt="was unset" || txt="was set"
        REPLY+="${(r:longest+1:: :)k}$txt"$'\n'
    done
} # ]]]
# FUNCTION: .zinit-format-env [[[
# Creates one-column text about FPATH or PATH elements
# added when given plugin was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
# $2 - if 1, then examine PATH, if 2, then examine FPATH
.zinit-format-env() {
    local uspl2="$1" which="$2"

    # Format PATH?
    if [[ "$which" = "1" ]]; then
        typeset -a elem
        elem=( "${(z@)ZINIT[PATH__$uspl2]}" )
    elif [[ "$which" = "2" ]]; then
        typeset -a elem
        elem=( "${(z@)ZINIT[FPATH__$uspl2]}" )
    fi

    # Enumerate elements added
    local answer="" e
    for e in "${elem[@]}"; do
        [[ -z "$e" ]] && continue
        e="${(Q)e}"
        answer+="$e"$'\n'
    done

    [[ -n "$answer" ]] && REPLY="$answer"
} # ]]]
# FUNCTION: .zinit-format-parameter [[[
# Creates one column text that lists global parameters that
# changed when the given plugin was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-parameter() {
    local uspl2="$1" infoc="${ZINIT[col-info]}" k

    builtin setopt localoptions extendedglob nokshglob noksharrays
    REPLY=""
    [[ "${ZINIT[PARAMETERS_PRE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PARAMETERS_POST__$uspl2]}" != *[$'! \t']* ]] && return 0

    typeset -A elem_pre elem_post
    elem_pre=( "${(z)ZINIT[PARAMETERS_PRE__$uspl2]}" )
    elem_post=( "${(z)ZINIT[PARAMETERS_POST__$uspl2]}" )

    # Find longest key and longest value
    integer longest=0 vlongest1=0 vlongest2=0
    local v1 v2
    for k in "${(k)elem_post[@]}"; do
        k="${(Q)k}"
        [[ "${#k}" -gt "$longest" ]] && longest="${#k}"

        v1="${(Q)elem_pre[$k]}"
        v2="${(Q)elem_post[$k]}"
        [[ "${#v1}" -gt "$vlongest1" ]] && vlongest1="${#v1}"
        [[ "${#v2}" -gt "$vlongest2" ]] && vlongest2="${#v2}"
    done

    # Enumerate parameters that changed. A key
    # always exists in both of the arrays
    local answer="" k
    for k in "${(k)elem_post[@]}"; do
        v1="${(Q)elem_pre[$k]}"
        v2="${(Q)elem_post[$k]}"
        k="${(Q)k}"

        k="${(r:longest+1:: :)k}"
        v1="${(l:vlongest1+1:: :)v1}"
        v2="${(r:vlongest2+1:: :)v2}"
        answer+="$k ${infoc}[$v1 -> $v2]${ZINIT[col-rst]}"$'\n'
    done

    [[ -n "$answer" ]] && REPLY="$answer"

    return 0
} # ]]]

#
# Completion functions
#

# FUNCTION: .zinit-get-completion-owner [[[
# Returns "user---plugin" string (uspl1 format) of plugin that
# owns given completion.
#
# Both :A and readlink will be used, then readlink's output if
# results differ. Readlink might not be available.
#
# :A will read the link "twice" and give the final repository
# directory, possibly without username in the uspl format;
# readlink will read the link "once"
#
# $1 - absolute path to completion file (in COMPLETIONS_DIR)
# $2 - readlink command (":" or "readlink")
.zinit-get-completion-owner() {
    setopt localoptions extendedglob nokshglob noksharrays noshwordsplit
    local cpath="$1"
    local readlink_cmd="$2"
    local in_plugin_path tmp

    # Try to go not too deep into resolving the symlink,
    # to have the name as it is in .zinit/plugins
    # :A goes deep, descends fully to origin directory
    # Readlink just reads what symlink points to
    in_plugin_path="${cpath:A}"
    tmp=$( "$readlink_cmd" "$cpath" )
    # This in effect works as: "if different, then readlink"
    [[ -n "$tmp" ]] && in_plugin_path="$tmp"

    if [[ "$in_plugin_path" != "$cpath" && -r "$in_plugin_path" ]]; then
        # Get the user---plugin part of path
        while [[ "$in_plugin_path" != ${ZINIT[PLUGINS_DIR]}/[^/]## && "$in_plugin_path" != "/" && "$in_plugin_path" != "." ]]; do
            in_plugin_path="${in_plugin_path:h}"
        done
        in_plugin_path="${in_plugin_path:t}"

        if [[ -z "$in_plugin_path" ]]; then
            in_plugin_path="${tmp:h}"
        fi
    else
        # readlink and :A have nothing
        in_plugin_path="[unknown]"
    fi

    REPLY="$in_plugin_path"
} # ]]]
# FUNCTION: .zinit-get-completion-owner-uspl2col [[[
# For shortening of code - returns colorized plugin name
# that owns given completion.
#
# $1 - absolute path to completion file (in COMPLETIONS_DIR)
# $2 - readlink command (":" or "readlink")
.zinit-get-completion-owner-uspl2col() {
    # "cpath" "readline_cmd"
    .zinit-get-completion-owner "$1" "$2"
    .zinit-any-colorify-as-uspl2 "$REPLY"
} # ]]]
# FUNCTION: .zinit-find-completions-of-plugin [[[
# Searches for completions owned by given plugin.
# Returns them in `reply' array.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-find-completions-of-plugin() {
    builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
    .zinit-any-to-user-plugin "$1" "$2"
    local user="${reply[-2]}" plugin="${reply[-1]}" uspl
    [[ "$user" = "%" ]] && uspl="${user}${plugin}" || uspl="${reply[-2]}${reply[-2]:+---}${reply[-1]//\//---}"

    reply=( "${ZINIT[PLUGINS_DIR]}/$uspl"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
} # ]]]
# FUNCTION: .zinit-check-comp-consistency [[[
# Zinit creates symlink for each installed completion.
# This function checks whether given completion (i.e.
# file like "_mkdir") is indeed a symlink. Backup file
# is a completion that is disabled - has the leading "_"
# removed.
#
# $1 - path to completion within plugin's directory
# $2 - path to backup file within plugin's directory
.zinit-check-comp-consistency() {
    local cfile="$1" bkpfile="$2"
    integer error="$3"

    # bkpfile must be a symlink
    if [[ -e "$bkpfile" && ! -L "$bkpfile" ]]; then
        builtin print "${ZINIT[col-error]}Warning: completion's backup file \`${bkpfile:t}' isn't a symlink${ZINIT[col-rst]}"
        error=1
    fi

    # cfile must be a symlink
    if [[ -e "$cfile" && ! -L "$cfile" ]]; then
        builtin print "${ZINIT[col-error]}Warning: completion file \`${cfile:t}' isn't a symlink${ZINIT[col-rst]}"
        error=1
    fi

    # Tell user that he can manually modify but should do it right
    (( error )) && builtin print "${ZINIT[col-error]}Manual edit of ${ZINIT[COMPLETIONS_DIR]} occured?${ZINIT[col-rst]}"
} # ]]]
# FUNCTION: .zinit-check-which-completions-are-installed [[[
# For each argument that each should be a path to completion
# within a plugin's dir, it checks whether that completion
# is installed - returns 0 or 1 on corresponding positions
# in reply.
#
# $1, ... - path to completion within plugin's directory
.zinit-check-which-completions-are-installed() {
    local i cfile bkpfile
    reply=( )
    for i in "$@"; do
        cfile="${i:t}"
        bkpfile="${cfile#_}"

        if [[ -e "${ZINIT[COMPLETIONS_DIR]}"/"$cfile" || -e "${ZINIT[COMPLETIONS_DIR]}"/"$bkpfile" ]]; then
            reply+=( "1" )
        else
            reply+=( "0" )
        fi
    done
} # ]]]
# FUNCTION: .zinit-check-which-completions-are-enabled [[[
# For each argument that each should be a path to completion
# within a plugin's dir, it checks whether that completion
# is disabled - returns 0 or 1 on corresponding positions
# in reply.
#
# Uninstalled completions will be reported as "0"
# - i.e. disabled
#
# $1, ... - path to completion within plugin's directory
.zinit-check-which-completions-are-enabled() {
    local i cfile
    reply=( )
    for i in "$@"; do
        cfile="${i:t}"

        if [[ -e "${ZINIT[COMPLETIONS_DIR]}"/"$cfile" ]]; then
            reply+=( "1" )
        else
            reply+=( "0" )
        fi
    done
} # ]]]
# FUNCTION: .zinit-uninstall-completions [[[
# Removes all completions of given plugin from Zshell (i.e. from FPATH).
# The FPATH is typically `~/.zinit/completions/'.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-uninstall-completions() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops

    typeset -a completions symlinked backup_comps
    local c cfile bkpfile
    integer action global_action=0

    .zinit-get-path "$1" "$2"
    [[ -e $REPLY ]] && {
        completions=( $REPLY/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
    } || {
        builtin print "No completions found for \`$1${${1:#(%|/)*}:+${2:+/}}$2'"
        return 1
    }

    symlinked=( ${ZINIT[COMPLETIONS_DIR]}/_[^_.]*~*.zwc )
    backup_comps=( ${ZINIT[COMPLETIONS_DIR]}/[^_.]*~*.zwc )

    (( ${+functions[.zinit-forget-completion]} )) || builtin source ${ZINIT[BIN_DIR]}"/zinit-install.zsh"

    # Delete completions if they are really there, either
    # as completions (_fname) or backups (fname)
    for c in ${completions[@]}; do
        action=0
        cfile=${c:t}
        bkpfile=${cfile#_}

        # Remove symlink to completion
        if [[ -n ${symlinked[(r)*/$cfile]} ]]; then
            command rm -f ${ZINIT[COMPLETIONS_DIR]}/$cfile
            action=1
        fi

        # Remove backup symlink (created by cdisable)
        if [[ -n ${backup_comps[(r)*/$bkpfile]} ]]; then
            command rm -f ${ZINIT[COMPLETIONS_DIR]}/$bkpfile
            action=1
        fi

        if (( action )); then
            +zi-log "{info}Uninstalling completion \`{file}$cfile{info}'{…}{rst}"
            # Make compinit notice the change
            .zinit-forget-completion "$cfile"
            (( global_action ++ ))
        else
            +zi-log "{info}Completion \`{file}$cfile{info}' not installed.{rst}"
        fi
    done

    if (( global_action > 0 )); then
        +zi-log "{info}Uninstalled {num}$global_action{info} completions.{rst}"
    fi

    .zinit-compinit >/dev/null
} # ]]]

#
# User-exposed functions
#

# FUNCTION: .zinit-pager [[[
# BusyBox less lacks the -X and -i options, so it can use more
.zinit-pager() {
    setopt LOCAL_OPTIONS EQUALS

    # Check if a non-interactive mode has been requested, either via a flag or a global setting.
    if (( OPTS[opt_-n,--no-pager] )) || [[ ${ZINIT[NO_PAGER]} = (1|true|on|yes) ]]; then
        # NON-INTERACTIVE MODE
        local max_lines=${ZINIT[NO_PAGER_MAX_LINES]}

        # Check if a line limit is explicitly set and is a valid non-negative integer.
        if [[ $max_lines =~ ^[0-9]+$ ]]; then
            if (( max_lines > 0 )); then
                # A positive number means limit the output to that many lines.
                head -n "$max_lines"
            else
                # A value of 0 means suppress all output from the pager completely.
                # `cat > /dev/null` is the most robust way to achieve this.
                cat > /dev/null
            fi
        else
            # No valid line limit is set, so show the full output without interaction.
            cat
        fi
        return 0
    else
        # INTERACTIVE MODE (Original Behavior)
        # Fall back to the default interactive pager if no non-interactive mode is set.
        if [[ ${${:-=less}:A:t} = busybox* ]] {
            more 2>/dev/null
            (( ${+commands[more]} ))
        } else {
            less -FRXi 2>/dev/null
            (( ${+commands[less]} ))
        }
        (( $? )) && cat
        return 0
    fi
} # ]]]

# FUNCTION: .zinit-build-module [[[
# Performs ./configure && make on the module and displays information
# how to load the module in .zshrc.
.zinit-build-module() {
    setopt localoptions localtraps
    trap 'return 1' INT TERM
    if command git -C "${ZINIT[MODULE_DIR]}" rev-parse 2>/dev/null; then
        command git -C "${ZINIT[MODULE_DIR]}" clean -d -f -f
        command git -C "${ZINIT[MODULE_DIR]}" reset --hard HEAD
        command git -C "${ZINIT[MODULE_DIR]}" pull
    else
        command git clone "https://github.com/zdharma-continuum/zinit-module.git" "${ZINIT[MODULE_DIR]}" || {
            builtin print "${ZINIT[col-error]}Failed to clone module repo${ZINIT[col-rst]}"
            return 1
        }
    fi
    ( builtin cd -q "${ZINIT[MODULE_DIR]}"
      +zi-log "{pname}== Building module zdharma-continuum/zinit-module, running: make clean, then ./configure and then make =={rst}"
      +zi-log "{pname}== The module sources are located at: "${ZINIT[MODULE_DIR]}" =={rst}"
      if [[ -f Makefile ]] {
          if [[ "$1" = "--clean" ]] {
              noglob +zi-log {p}-- make distclean --{rst}
              make distclean
              ((1))
          } else {
              noglob +zi-log {p}-- make clean --{rst}
              make clean
          }
      }
      noglob +zi-log  {p}-- ./configure --{rst}
      CPPFLAGS=-I/usr/local/include CFLAGS="-g -Wall -O3" LDFLAGS=-L/usr/local/lib ./configure --disable-gdbm --without-tcsetpgrp && {
          noglob +zi-log {p}-- make --{rst}
          if { make } {
            [[ -f Src/zdharma_continuum/zinit.so ]] && cp -vf Src/zdharma_continuum/zinit.{so,bundle}
            noglob +zi-log "{info}Module has been built correctly.{rst}"
            .zinit-module info
          } else {
              noglob +zi-log  "{error}Module didn't build.{rst} "
              .zinit-module info --link
          }
      }
      builtin print $EPOCHSECONDS >! "${ZINIT[MAN_DIR]}/COMPILED_AT"
    )
} # ]]]
# FUNCTION: .zinit-module [[[
# Function that has sub-commands passed as long-options (with two dashes, --).
# It's an attempt to plugin only this one function into `zinit' function
# defined in zinit.zsh, to not make this file longer than it's needed.
.zinit-module() {
    if [[ "$1" = "build" ]]; then
        .zinit-build-module "${@[2,-1]}"
    elif [[ "$1" = "info" ]]; then
        if [[ "$2" = "--link" ]]; then
              builtin print -r "You can copy the error messages and submit"
              builtin print -r "error-report at: https://github.com/zdharma-continuum/zinit-module/issues"
        else
            builtin print -r "To load the module, add following 2 lines to .zshrc, at top:"
            builtin print -r "    module_path+=( \"${ZINIT[MODULE_DIR]}/Src\" )"
            builtin print -r "    zmodload zdharma_continuum/zinit"
            builtin print -r ""
            builtin print -r "After loading, use command \`zpmod' to communicate with the module."
            builtin print -r "See \`zpmod -h' for more information."
        fi
    elif [[ "$1" = (help|usage) ]]; then
        builtin print -r "Usage: zinit module {build|info|help} [options]"
        builtin print -r "       zinit module build [--clean]"
        builtin print -r "       zinit module info [--link]"
        builtin print -r ""
        builtin print -r "To start using the zinit Zsh module run: \`zinit module build'"
        builtin print -r "and follow the instructions. Option --clean causes \`make distclean'"
        builtin print -r "to be run. To display the instructions on loading the module, run:"
... truncated; 2,816 more lines
tests/recorder_corpus/zinit/zinit-autoload.zsh — 3,616 LOC
#!/usr/bin/env zsh
#
# zdharma-continuum/zinit/zinit-autoload.zsh
# Copyright (c) 2016-2021 Sebastian Gniazdowski
# Copyright (c) 2021-2023 zdharma-continuum
# Homepage: https://github.com/zdharma-continuum/zinit
# License: MIT License
#

builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { builtin print -P "${ZINIT[col-error]}ERROR:%f%b Couldn't find ${ZINIT[col-obj]}zinit-side.zsh%f%b."; return 1; }

ZINIT[EXTENDED_GLOB]=""

#
# Backend, low level functions
#

# FUNCTION: .zinit-unregister-plugin [[[
# Removes the plugin from ZINIT_REGISTERED_PLUGINS array and from the
# zsh_loaded_plugins array (managed according to the plugin standard)
.zinit-unregister-plugin() {
    .zinit-any-to-user-plugin "$1" "$2"
    local uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" \
        teleid="$3"

    # If not found, the index will be length+1
    ZINIT_REGISTERED_PLUGINS[${ZINIT_REGISTERED_PLUGINS[(i)$uspl2]}]=()
    # Support Zsh plugin standard
    zsh_loaded_plugins[${zsh_loaded_plugins[(i)$teleid]}]=()
    ZINIT[STATES__$uspl2]="0"
} # ]]]
# FUNCTION: .zinit-diff-functions-compute [[[
# Computes FUNCTIONS that holds new functions added by plugin.
# Uses data gathered earlier by .zinit-diff-functions().
#
# $1 - user/plugin
.zinit-diff-functions-compute() {
    local uspl2="$1"

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces

    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[FUNCTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[FUNCTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A func
    local i

    # This includes new functions. Quoting is kept (i.e. no i=${(Q)i})
    for i in "${(z)ZINIT[FUNCTIONS_AFTER__$uspl2]}"; do
        func[$i]=1
    done

    # Remove duplicated entries, i.e. existing before. Quoting is kept
    for i in "${(z)ZINIT[FUNCTIONS_BEFORE__$uspl2]}"; do
        # if would do unset, then: func[opp+a\[]: invalid parameter name
        func[$i]=0
    done

    # Store the functions, associating them with plugin ($uspl2)
    ZINIT[FUNCTIONS__$uspl2]=""
    for i in "${(onk)func[@]}"; do
        [[ "${func[$i]}" = "1" ]] && ZINIT[FUNCTIONS__$uspl2]+="$i "
    done

    return 0
} # ]]]
# FUNCTION: .zinit-diff-options-compute [[[
# Computes OPTIONS that holds options changed by plugin.
# Uses data gathered earlier by .zinit-diff-options().
#
# $1 - user/plugin
.zinit-diff-options-compute() {
    local uspl2="$1"

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[OPTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[OPTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A opts_before opts_after opts
    opts_before=( "${(z)ZINIT[OPTIONS_BEFORE__$uspl2]}" )
    opts_after=( "${(z)ZINIT[OPTIONS_AFTER__$uspl2]}" )
    opts=( )

    # Iterate through first array (keys the same
    # on both of them though) and test for a change
    local key
    for key in "${(k)opts_before[@]}"; do
        if [[ "${opts_before[$key]}" != "${opts_after[$key]}" ]]; then
            opts[$key]="${opts_before[$key]}"
        fi
    done

    # Serialize for reporting
    local IFS=" "
    ZINIT[OPTIONS__$uspl2]="${(kv)opts[@]}"
    return 0
} # ]]]
# FUNCTION: .zinit-diff-env-compute [[[
# Computes ZINIT_PATH, ZINIT_FPATH that hold (f)path components
# added by plugin. Uses data gathered earlier by .zinit-diff-env().
#
# $1 - user/plugin
.zinit-diff-env-compute() {
    local uspl2="$1"
    typeset -a tmp

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[PATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
    [[ "${ZINIT[FPATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[FPATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    typeset -A path_state fpath_state
    local i

    #
    # PATH processing
    #

    # This includes new path elements
    for i in "${(z)ZINIT[PATH_AFTER__$uspl2]}"; do
        path_state[${(Q)i}]=1
    done

    # Remove duplicated entries, i.e. existing before
    for i in "${(z)ZINIT[PATH_BEFORE__$uspl2]}"; do
        unset "path_state[${(Q)i}]"
    done

    # Store the path elements, associating them with plugin ($uspl2)
    ZINIT[PATH__$uspl2]=""
    for i in "${(onk)path_state[@]}"; do
        ZINIT[PATH__$uspl2]+="${(q)i} "
    done

    #
    # FPATH processing
    #

    # This includes new path elements
    for i in "${(z)ZINIT[FPATH_AFTER__$uspl2]}"; do
        fpath_state[${(Q)i}]=1
    done

    # Remove duplicated entries, i.e. existing before
    for i in "${(z)ZINIT[FPATH_BEFORE__$uspl2]}"; do
        unset "fpath_state[${(Q)i}]"
    done

    # Store the path elements, associating them with plugin ($uspl2)
    ZINIT[FPATH__$uspl2]=""
    for i in "${(onk)fpath_state[@]}"; do
        ZINIT[FPATH__$uspl2]+="${(q)i} "
    done

    return 0
} # ]]]
# FUNCTION: .zinit-diff-parameter-compute [[[
# Computes ZINIT_PARAMETERS_PRE, ZINIT_PARAMETERS_POST that hold
# parameters created or changed (their type) by plugin. Uses
# data gathered earlier by .zinit-diff-parameter().
#
# $1 - user/plugin
.zinit-diff-parameter-compute() {
    local uspl2="$1"
    typeset -a tmp

    # Cannot run diff if *_BEFORE or *_AFTER variable is not set
    # Following is paranoid for *_BEFORE and *_AFTER being only spaces
    builtin setopt localoptions extendedglob nokshglob noksharrays
    [[ "${ZINIT[PARAMETERS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PARAMETERS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1

    # Un-concatenated parameters from moment of diff start and of diff end
    typeset -A params_before params_after
    params_before=( "${(z)ZINIT[PARAMETERS_BEFORE__$uspl2]}" )
    params_after=( "${(z)ZINIT[PARAMETERS_AFTER__$uspl2]}" )

    # The parameters that changed, with save of what
    # parameter was when diff started or when diff ended
    typeset -A params_pre params_post
    params_pre=( )
    params_post=( )

    # Iterate through all existing keys, before or after diff,
    # i.e. after all variables that were somehow live across
    # the diffing process
    local key
    typeset -aU keys
    keys=( "${(k)params_after[@]}" );
    keys=( "${keys[@]}" "${(k)params_before[@]}" );
    for key in "${keys[@]}"; do
        key="${(Q)key}"
        [[ "${params_after[$key]}" = *local* ]] && continue
        if [[ "${params_after[$key]}" != "${params_before[$key]}" ]]; then
            # Empty for a new param, a type otherwise
            [[ -z "${params_before[$key]}" ]] && params_before[$key]="\"\""
            params_pre[$key]="${params_before[$key]}"

            # Current type, can also be empty, when plugin
            # unsets a parameter
            [[ -z "${params_after[$key]}" ]] && params_after[$key]="\"\""
            params_post[$key]="${params_after[$key]}"
        fi
    done

    # Serialize for reporting
    ZINIT[PARAMETERS_PRE__$uspl2]="${(j: :)${(qkv)params_pre[@]}}"
    ZINIT[PARAMETERS_POST__$uspl2]="${(j: :)${(qkv)params_post[@]}}"

    return 0
} # ]]]
# FUNCTION: .zinit-any-to-uspl2 [[[
# Converts given plugin-spec to format that's used in keys for hash tables.
# So basically, creates string "user/plugin" (this format is called: uspl2).
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-any-to-uspl2() {
    .zinit-any-to-user-plugin "$1" "$2"
    [[ "${reply[-2]}" = "%" ]] && REPLY="${reply[-2]}${reply[-1]}" || REPLY="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]//---//}"
} # ]]]
# FUNCTION: .zinit-save-set-extendedglob [[[
# Enables extendedglob-option first saving if it was already
# enabled, for restoration of this state later.
.zinit-save-set-extendedglob() {
    [[ -o "extendedglob" ]] && ZINIT[EXTENDED_GLOB]="1" || ZINIT[EXTENDED_GLOB]="0"
    builtin setopt extendedglob
} # ]]]
# FUNCTION: .zinit-restore-extendedglob [[[
# Restores extendedglob-option from state saved earlier.
.zinit-restore-extendedglob() {
    [[ "${ZINIT[EXTENDED_GLOB]}" = "0" ]] && builtin unsetopt extendedglob || builtin setopt extendedglob
} # ]]]
# FUNCTION: .zinit-prepare-readlink [[[
# Prepares readlink command, used for establishing completion's owner.
#
# $REPLY = ":" or "readlink"
.zinit-prepare-readlink() {
    REPLY=":"
    if type readlink 2>/dev/null 1>&2; then
        REPLY="readlink"
    fi
} # ]]]
# FUNCTION: .zinit-clear-report-for [[[
# Clears all report data for given user/plugin. This is
# done by resetting all related global ZINIT_* hashes.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-clear-report-for() {
    .zinit-any-to-uspl2 "$1" "$2"

    # Shadowing
    ZINIT_REPORTS[$REPLY]=""
    ZINIT[BINDKEYS__$REPLY]=""
    ZINIT[ZSTYLES__$REPLY]=""
    ZINIT[ALIASES__$REPLY]=""
    ZINIT[WIDGETS_SAVED__$REPLY]=""
    ZINIT[WIDGETS_DELETE__$REPLY]=""

    # Function diffing
    ZINIT[FUNCTIONS__$REPLY]=""
    ZINIT[FUNCTIONS_BEFORE__$REPLY]=""
    ZINIT[FUNCTIONS_AFTER__$REPLY]=""

    # Option diffing
    ZINIT[OPTIONS__$REPLY]=""
    ZINIT[OPTIONS_BEFORE__$REPLY]=""
    ZINIT[OPTIONS_AFTER__$REPLY]=""

    # Environment diffing
    ZINIT[PATH__$REPLY]=""
    ZINIT[PATH_BEFORE__$REPLY]=""
    ZINIT[PATH_AFTER__$REPLY]=""
    ZINIT[FPATH__$REPLY]=""
    ZINIT[FPATH_BEFORE__$REPLY]=""
    ZINIT[FPATH_AFTER__$REPLY]=""

    # Parameter diffing
    ZINIT[PARAMETERS_PRE__$REPLY]=""
    ZINIT[PARAMETERS_POST__$REPLY]=""
    ZINIT[PARAMETERS_BEFORE__$REPLY]=""
    ZINIT[PARAMETERS_AFTER__$REPLY]=""
} # ]]]
# FUNCTION: .zinit-exists-message [[[
# Checks if plugin is loaded. Testable. Also outputs error
# message if plugin is not loaded.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zinit-exists-message() {
    .zinit-any-to-uspl2 "$1" "$2"
    if [[ -z "${ZINIT_REGISTERED_PLUGINS[(r)$REPLY]}" ]]; then
        .zinit-any-colorify-as-uspl2 "$1" "$2"
        builtin print "${ZINIT[col-error]}No such plugin${ZINIT[col-rst]} $REPLY"
        return 1
    fi
    return 0
} # ]]]
# FUNCTION: .zinit-at-eval [[[
.zinit-at-eval() {
    local atclone="$2" atpull="$1"
    integer retval
    @zinit-substitute atclone atpull
    [[ $atpull = "%atclone" ]] && { eval "$atclone"; retval=$?; } || { eval "$atpull"; retval=$?; }
    return $retval
} # ]]]

#
# Format functions
#

# FUNCTION: .zinit-format-functions [[[
# Creates a one or two columns text with functions created
# by given plugin.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-functions() {
    local uspl2="$1"

    typeset -a func
    func=( "${(z)ZINIT[FUNCTIONS__$uspl2]}" )

    # Get length of longest left-right string pair,
    # and length of longest left string
    integer longest=0 longest_left=0 cur_left_len=0 count=1
    local f
    for f in "${(on)func[@]}"; do
        [[ -z "${#f}" ]] && continue
        f="${(Q)f}"

        # Compute for elements in left column,
        # ones that will be paded with spaces
        if (( count ++ % 2 != 0 )); then
            [[ "${#f}" -gt "$longest_left" ]] && longest_left="${#f}"
            cur_left_len="${#f}"
        else
            cur_left_len+="${#f}"
            cur_left_len+=1 # For separating space
            [[ "$cur_left_len" -gt "$longest" ]] && longest="$cur_left_len"
        fi
    done

    # Output in one or two columns
    local answer=""
    count=1
    for f in "${(on)func[@]}"; do
        [[ -z "$f" ]] && continue
        f="${(Q)f}"

        if (( COLUMNS >= longest )); then
            if (( count ++ % 2 != 0 )); then
                answer+="${(r:longest_left+1:: :)f}"
            else
                answer+="$f"$'\n'
            fi
        else
            answer+="$f"$'\n'
        fi
    done
    REPLY="$answer"
    # == 0 is: next element would have newline (postfix addition in "count ++")
    (( COLUMNS >= longest && count % 2 == 0 )) && REPLY="$REPLY"$'\n'
} # ]]]
# FUNCTION: .zinit-format-options [[[
# Creates one-column text about options that changed when
# plugin "$1" was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-options() {
    local uspl2="$1"

    REPLY=""

    # Paranoid, don't want bad key/value pair error
    integer empty=0
    .zinit-save-set-extendedglob
    [[ "${ZINIT[OPTIONS__$uspl2]}" != *[$'! \t']* ]] && empty=1
    .zinit-restore-extendedglob
    (( empty )) && return 0

    typeset -A opts
    opts=( "${(z)ZINIT[OPTIONS__$uspl2]}" )

    # Get length of longest option
    integer longest=0
    local k
    for k in "${(kon)opts[@]}"; do
        [[ "${#k}" -gt "$longest" ]] && longest="${#k}"
    done

    # Output in one column
    local txt
    for k in "${(kon)opts[@]}"; do
        [[ "${opts[$k]}" = "on" ]] && txt="was unset" || txt="was set"
        REPLY+="${(r:longest+1:: :)k}$txt"$'\n'
    done
} # ]]]
# FUNCTION: .zinit-format-env [[[
# Creates one-column text about FPATH or PATH elements
# added when given plugin was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
# $2 - if 1, then examine PATH, if 2, then examine FPATH
.zinit-format-env() {
    local uspl2="$1" which="$2"

    # Format PATH?
    if [[ "$which" = "1" ]]; then
        typeset -a elem
        elem=( "${(z@)ZINIT[PATH__$uspl2]}" )
    elif [[ "$which" = "2" ]]; then
        typeset -a elem
        elem=( "${(z@)ZINIT[FPATH__$uspl2]}" )
    fi

    # Enumerate elements added
    local answer="" e
    for e in "${elem[@]}"; do
        [[ -z "$e" ]] && continue
        e="${(Q)e}"
        answer+="$e"$'\n'
    done

    [[ -n "$answer" ]] && REPLY="$answer"
} # ]]]
# FUNCTION: .zinit-format-parameter [[[
# Creates one column text that lists global parameters that
# changed when the given plugin was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zinit-format-parameter() {
    local uspl2="$1" infoc="${ZINIT[col-info]}" k

    builtin setopt localoptions extendedglob nokshglob noksharrays
    REPLY=""
    [[ "${ZINIT[PARAMETERS_PRE__$uspl2]}" != *[$'! \t']* || "${ZINIT[PARAMETERS_POST__$uspl2]}" != *[$'! \t']* ]] && return 0

    typeset -A elem_pre elem_post
    elem_pre=( "${(z)ZINIT[PARAMETERS_PRE__$uspl2]}" )
    elem_post=( "${(z)ZINIT[PARAMETERS_POST__$uspl2]}" )

    # Find longest key and longest value
    integer longest=0 vlongest1=0 vlongest2=0
    local v1 v2
    for k in "${(k)elem_post[@]}"; do
        k="${(Q)k}"
        [[ "${#k}" -gt "$longest" ]] && longest="${#k}"

        v1="${(Q)elem_pre[$k]}"
        v2="${(Q)elem_post[$k]}"
        [[ "${#v1}" -gt "$vlongest1" ]] && vlongest1="${#v1}"
        [[ "${#v2}" -gt "$vlongest2" ]] && vlongest2="${#v2}"
    done

    # Enumerate parameters that changed. A key
    # always exists in both of the arrays
    local answer="" k
    for k in "${(k)elem_post[@]}"; do
        v1="${(Q)elem_pre[$k]}"
        v2="${(Q)elem_post[$k]}"
        k="${(Q)k}"

        k="${(r:longest+1:: :)k}"
        v1="${(l:vlongest1+1:: :)v1}"
        v2="${(r:vlongest2+1:: :)v2}"
        answer+="$k ${infoc}[$v1 -> $v2]${ZINIT[col-rst]}"$'\n'
    done

    [[ -n "$answer" ]] && REPLY="$answer"

    return 0
} # ]]]

#
# Completion functions
#

# FUNCTION: .zinit-get-completion-owner [[[
# Returns "user---plugin" string (uspl1 format) of plugin that
# owns given completion.
#
# Both :A and readlink will be used, then readlink's output if
# results differ. Readlink might not be available.
#
# :A will read the link "twice" and give the final repository
# directory, possibly without username in the uspl format;
# readlink will read the link "once"
#
# $1 - absolute path to completion file (in COMPLETIONS_DIR)
# $2 - readlink command (":" or "readlink")
.zinit-get-completion-owner() {
    setopt localoptions extendedglob nokshglob noksharrays noshwordsplit
    local cpath="$1"
    local readlink_cmd="$2"
    local in_plugin_path tmp

    # Try to go not too deep into resolving the symlink,
    # to have the name as it is in .zinit/plugins
    # :A goes deep, descends fully to origin directory
    # Readlink just reads what symlink points to
    in_plugin_path="${cpath:A}"
    tmp=$( "$readlink_cmd" "$cpath" )
    # This in effect works as: "if different, then readlink"
    [[ -n "$tmp" ]] && in_plugin_path="$tmp"

    if [[ "$in_plugin_path" != "$cpath" && -r "$in_plugin_path" ]]; then
        # Get the user---plugin part of path
        while [[ "$in_plugin_path" != ${ZINIT[PLUGINS_DIR]}/[^/]## && "$in_plugin_path" != "/" && "$in_plugin_path" != "." ]]; do
            in_plugin_path="${in_plugin_path:h}"
        done
        in_plugin_path="${in_plugin_path:t}"

        if [[ -z "$in_plugin_path" ]]; then
            in_plugin_path="${tmp:h}"
        fi
    else
        # readlink and :A have nothing
        in_plugin_path="[unknown]"
    fi

    REPLY="$in_plugin_path"
} # ]]]
# FUNCTION: .zinit-get-completion-owner-uspl2col [[[
# For shortening of code - returns colorized plugin name
# that owns given completion.
#
# $1 - absolute path to completion file (in COMPLETIONS_DIR)
# $2 - readlink command (":" or "readlink")
.zinit-get-completion-owner-uspl2col() {
    # "cpath" "readline_cmd"
    .zinit-get-completion-owner "$1" "$2"
    .zinit-any-colorify-as-uspl2 "$REPLY"
} # ]]]
# FUNCTION: .zinit-find-completions-of-plugin [[[
# Searches for completions owned by given plugin.
# Returns them in `reply' array.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-find-completions-of-plugin() {
    builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
    .zinit-any-to-user-plugin "$1" "$2"
    local user="${reply[-2]}" plugin="${reply[-1]}" uspl
    [[ "$user" = "%" ]] && uspl="${user}${plugin}" || uspl="${reply[-2]}${reply[-2]:+---}${reply[-1]//\//---}"

    reply=( "${ZINIT[PLUGINS_DIR]}/$uspl"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
} # ]]]
# FUNCTION: .zinit-check-comp-consistency [[[
# Zinit creates symlink for each installed completion.
# This function checks whether given completion (i.e.
# file like "_mkdir") is indeed a symlink. Backup file
# is a completion that is disabled - has the leading "_"
# removed.
#
# $1 - path to completion within plugin's directory
# $2 - path to backup file within plugin's directory
.zinit-check-comp-consistency() {
    local cfile="$1" bkpfile="$2"
    integer error="$3"

    # bkpfile must be a symlink
    if [[ -e "$bkpfile" && ! -L "$bkpfile" ]]; then
        builtin print "${ZINIT[col-error]}Warning: completion's backup file \`${bkpfile:t}' isn't a symlink${ZINIT[col-rst]}"
        error=1
    fi

    # cfile must be a symlink
    if [[ -e "$cfile" && ! -L "$cfile" ]]; then
        builtin print "${ZINIT[col-error]}Warning: completion file \`${cfile:t}' isn't a symlink${ZINIT[col-rst]}"
        error=1
    fi

    # Tell user that he can manually modify but should do it right
    (( error )) && builtin print "${ZINIT[col-error]}Manual edit of ${ZINIT[COMPLETIONS_DIR]} occured?${ZINIT[col-rst]}"
} # ]]]
# FUNCTION: .zinit-check-which-completions-are-installed [[[
# For each argument that each should be a path to completion
# within a plugin's dir, it checks whether that completion
# is installed - returns 0 or 1 on corresponding positions
# in reply.
#
# $1, ... - path to completion within plugin's directory
.zinit-check-which-completions-are-installed() {
    local i cfile bkpfile
    reply=( )
    for i in "$@"; do
        cfile="${i:t}"
        bkpfile="${cfile#_}"

        if [[ -e "${ZINIT[COMPLETIONS_DIR]}"/"$cfile" || -e "${ZINIT[COMPLETIONS_DIR]}"/"$bkpfile" ]]; then
            reply+=( "1" )
        else
            reply+=( "0" )
        fi
    done
} # ]]]
# FUNCTION: .zinit-check-which-completions-are-enabled [[[
# For each argument that each should be a path to completion
# within a plugin's dir, it checks whether that completion
# is disabled - returns 0 or 1 on corresponding positions
# in reply.
#
# Uninstalled completions will be reported as "0"
# - i.e. disabled
#
# $1, ... - path to completion within plugin's directory
.zinit-check-which-completions-are-enabled() {
    local i cfile
    reply=( )
    for i in "$@"; do
        cfile="${i:t}"

        if [[ -e "${ZINIT[COMPLETIONS_DIR]}"/"$cfile" ]]; then
            reply+=( "1" )
        else
            reply+=( "0" )
        fi
    done
} # ]]]
# FUNCTION: .zinit-uninstall-completions [[[
# Removes all completions of given plugin from Zshell (i.e. from FPATH).
# The FPATH is typically `~/.zinit/completions/'.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zinit-uninstall-completions() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops

    typeset -a completions symlinked backup_comps
    local c cfile bkpfile
    integer action global_action=0

    .zinit-get-path "$1" "$2"
    [[ -e $REPLY ]] && {
        completions=( $REPLY/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
    } || {
        builtin print "No completions found for \`$1${${1:#(%|/)*}:+${2:+/}}$2'"
        return 1
    }

    symlinked=( ${ZINIT[COMPLETIONS_DIR]}/_[^_.]*~*.zwc )
    backup_comps=( ${ZINIT[COMPLETIONS_DIR]}/[^_.]*~*.zwc )

    (( ${+functions[.zinit-forget-completion]} )) || builtin source ${ZINIT[BIN_DIR]}"/zinit-install.zsh"

    # Delete completions if they are really there, either
    # as completions (_fname) or backups (fname)
    for c in ${completions[@]}; do
        action=0
        cfile=${c:t}
        bkpfile=${cfile#_}

        # Remove symlink to completion
        if [[ -n ${symlinked[(r)*/$cfile]} ]]; then
            command rm -f ${ZINIT[COMPLETIONS_DIR]}/$cfile
            action=1
        fi

        # Remove backup symlink (created by cdisable)
        if [[ -n ${backup_comps[(r)*/$bkpfile]} ]]; then
            command rm -f ${ZINIT[COMPLETIONS_DIR]}/$bkpfile
            action=1
        fi

        if (( action )); then
            +zi-log "{info}Uninstalling completion \`{file}$cfile{info}'{…}{rst}"
            # Make compinit notice the change
            .zinit-forget-completion "$cfile"
            (( global_action ++ ))
        else
            +zi-log "{info}Completion \`{file}$cfile{info}' not installed.{rst}"
        fi
    done

    if (( global_action > 0 )); then
        +zi-log "{info}Uninstalled {num}$global_action{info} completions.{rst}"
    fi

    .zinit-compinit >/dev/null
} # ]]]

#
# User-exposed functions
#

# FUNCTION: .zinit-pager [[[
# BusyBox less lacks the -X and -i options, so it can use more
.zinit-pager() {
    setopt LOCAL_OPTIONS EQUALS

    # Check if a non-interactive mode has been requested, either via a flag or a global setting.
    if (( OPTS[opt_-n,--no-pager] )) || [[ ${ZINIT[NO_PAGER]} = (1|true|on|yes) ]]; then
        # NON-INTERACTIVE MODE
        local max_lines=${ZINIT[NO_PAGER_MAX_LINES]}

        # Check if a line limit is explicitly set and is a valid non-negative integer.
        if [[ $max_lines =~ ^[0-9]+$ ]]; then
            if (( max_lines > 0 )); then
                # A positive number means limit the output to that many lines.
                head -n "$max_lines"
            else
                # A value of 0 means suppress all output from the pager completely.
                # `cat > /dev/null` is the most robust way to achieve this.
                cat > /dev/null
            fi
        else
            # No valid line limit is set, so show the full output without interaction.
            cat
        fi
        return 0
    else
        # INTERACTIVE MODE (Original Behavior)
        # Fall back to the default interactive pager if no non-interactive mode is set.
        if [[ ${${:-=less}:A:t} = busybox* ]] {
            more 2>/dev/null
            (( ${+commands[more]} ))
        } else {
            less -FRXi 2>/dev/null
            (( ${+commands[less]} ))
        }
        (( $? )) && cat
        return 0
    fi
} # ]]]

# FUNCTION: .zinit-build-module [[[
# Performs ./configure && make on the module and displays information
# how to load the module in .zshrc.
.zinit-build-module() {
    setopt localoptions localtraps
    trap 'return 1' INT TERM
    if command git -C "${ZINIT[MODULE_DIR]}" rev-parse 2>/dev/null; then
        command git -C "${ZINIT[MODULE_DIR]}" clean -d -f -f
        command git -C "${ZINIT[MODULE_DIR]}" reset --hard HEAD
        command git -C "${ZINIT[MODULE_DIR]}" pull
    else
        command git clone "https://github.com/zdharma-continuum/zinit-module.git" "${ZINIT[MODULE_DIR]}" || {
            builtin print "${ZINIT[col-error]}Failed to clone module repo${ZINIT[col-rst]}"
            return 1
        }
    fi
    ( builtin cd -q "${ZINIT[MODULE_DIR]}"
      +zi-log "{pname}== Building module zdharma-continuum/zinit-module, running: make clean, then ./configure and then make =={rst}"
      +zi-log "{pname}== The module sources are located at: "${ZINIT[MODULE_DIR]}" =={rst}"
      if [[ -f Makefile ]] {
          if [[ "$1" = "--clean" ]] {
              noglob +zi-log {p}-- make distclean --{rst}
              make distclean
              ((1))
          } else {
              noglob +zi-log {p}-- make clean --{rst}
              make clean
          }
      }
      noglob +zi-log  {p}-- ./configure --{rst}
      CPPFLAGS=-I/usr/local/include CFLAGS="-g -Wall -O3" LDFLAGS=-L/usr/local/lib ./configure --disable-gdbm --without-tcsetpgrp && {
          noglob +zi-log {p}-- make --{rst}
          if { make } {
            [[ -f Src/zdharma_continuum/zinit.so ]] && cp -vf Src/zdharma_continuum/zinit.{so,bundle}
            noglob +zi-log "{info}Module has been built correctly.{rst}"
            .zinit-module info
          } else {
              noglob +zi-log  "{error}Module didn't build.{rst} "
              .zinit-module info --link
          }
      }
      builtin print $EPOCHSECONDS >! "${ZINIT[MAN_DIR]}/COMPILED_AT"
    )
} # ]]]
# FUNCTION: .zinit-module [[[
# Function that has sub-commands passed as long-options (with two dashes, --).
# It's an attempt to plugin only this one function into `zinit' function
# defined in zinit.zsh, to not make this file longer than it's needed.
.zinit-module() {
    if [[ "$1" = "build" ]]; then
        .zinit-build-module "${@[2,-1]}"
    elif [[ "$1" = "info" ]]; then
        if [[ "$2" = "--link" ]]; then
              builtin print -r "You can copy the error messages and submit"
              builtin print -r "error-report at: https://github.com/zdharma-continuum/zinit-module/issues"
        else
            builtin print -r "To load the module, add following 2 lines to .zshrc, at top:"
            builtin print -r "    module_path+=( \"${ZINIT[MODULE_DIR]}/Src\" )"
            builtin print -r "    zmodload zdharma_continuum/zinit"
            builtin print -r ""
            builtin print -r "After loading, use command \`zpmod' to communicate with the module."
            builtin print -r "See \`zpmod -h' for more information."
        fi
    elif [[ "$1" = (help|usage) ]]; then
        builtin print -r "Usage: zinit module {build|info|help} [options]"
        builtin print -r "       zinit module build [--clean]"
        builtin print -r "       zinit module info [--link]"
        builtin print -r ""
        builtin print -r "To start using the zinit Zsh module run: \`zinit module build'"
        builtin print -r "and follow the instructions. Option --clean causes \`make distclean'"
        builtin print -r "to be run. To display the instructions on loading the module, run:"
... truncated; 2,816 more lines
.claude/worktrees/agent-a11a320a48a837c68/tests/recorder_corpus/zinit/zinit.zsh — 3,351 LOC
#
# zdharma-continuum/zinit/zinit.zsh
# Copyright (c) 2016-2021 Sebastian Gniazdowski
# Copyright (c) 2021-2023 zdharma-continuum
# Homepage: https://github.com/zdharma-continuum/zinit
# License: MIT License
#

#
# Main state variables.
#

typeset -gaH ZINIT_REGISTERED_PLUGINS ZINIT_TASKS ZINIT_RUN
typeset -ga zsh_loaded_plugins
if (( !${#ZINIT_TASKS} )) { ZINIT_TASKS=( "<no-data>" ); }
# Snippets loaded, url -> file name.
typeset -gAH ZINIT ZINIT_SNIPPETS ZINIT_REPORTS ZINIT_ICES ZINIT_SICE ZINIT_CUR_BIND_MAP ZINIT_EXTS ZINIT_EXTS2
typeset -gaH ZINIT_COMPDEF_REPLAY

# Compatibility with pre-rename project (Zplugin).
typeset -gAH ZPLGM
ZINIT=( "${(kv)ZPLGM[@]}" "${(kv)ZINIT[@]}" )
unset ZPLGM

#
# Common needed values.
#

[[ ! -e ${ZINIT[BIN_DIR]}/zinit.zsh ]] && ZINIT[BIN_DIR]=

# Respect the plugin standard too.
ZINIT[ZERO]="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
[[ ! -o functionargzero || ${options[posixargzero]} = on || ${ZINIT[ZERO]} != */* ]] && ZINIT[ZERO]="${(%):-%N}"

: ${ZINIT[BIN_DIR]:="${ZINIT[ZERO]:h}"}
[[ ${ZINIT[BIN_DIR]} = \~* ]] && ZINIT[BIN_DIR]=${~ZINIT[BIN_DIR]}

# Make ZINIT[BIN_DIR] path absolute.
ZINIT[BIN_DIR]="${${(M)ZINIT[BIN_DIR]:#/*}:-$PWD/${ZINIT[BIN_DIR]}}"

# Final test of ZINIT[BIN_DIR].
if [[ ! -e ${ZINIT[BIN_DIR]}/zinit.zsh ]]; then
    builtin print -P "%F{196}Could not establish ZINIT[BIN_DIR] hash field. It should point where Zinit's Git repository is.%f"
    return 1
fi

# User can override ZINIT[HOME_DIR].
if [[ -z ${ZINIT[HOME_DIR]} ]]; then
    # Search for zinit home in the usual locations
    if [[ -d ${XDG_DATA_HOME:-${HOME}/.local/share}/zinit ]]; then
        ZINIT[HOME_DIR]="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
    elif [[ -d $HOME/.zinit ]]; then
        ZINIT[HOME_DIR]="$HOME/.zinit"
    elif [[ -d ${ZDOTDIR:-$HOME}/.zinit ]]; then
        ZINIT[HOME_DIR]="${ZDOTDIR:-$HOME}/.zinit"
    elif [[ -d $HOME/.zplugin ]]; then
        ZINIT[HOME_DIR]="$HOME/.zplugin"
    elif [[ -d ${ZDOTDIR:-$HOME}/.zplugin ]]; then
        ZINIT[HOME_DIR]="${ZDOTDIR:-$HOME}/.zplugin"
    else
        ZINIT[HOME_DIR]="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
    fi
fi

if [[ -z ${ZINIT[LIST_COMMAND]} ]]; then
    if (( ${+commands[eza]} )); then
        ZINIT[LIST_COMMAND]='eza --color=always --tree --icons -L3'
    elif (( ${+commands[exa]} )); then
        ZINIT[LIST_COMMAND]='exa --color=always --tree --icons -L3'
    elif (( ${+commands[tree]} )); then
        ZINIT[LIST_COMMAND]='tree -L 3 -C --charset utf-8'
    else
        ZINIT[LIST_COMMAND]='ls --tree'
    fi
fi

ZINIT[ice-list]="\
\!bash|\!csh|\!ksh|\!sh|\
aliases|as|atclone|atdelete|atinit|atload|atpull|autoload|\
bash|binary|bindmap|blockf|bpick|build|\
cloneonly|cloneopts|cmake|compile|completions|configure|countdown|cp|csh|\
debug|depth|\
extract|\
from|git|\
has|\
id-as|if|install|is-snippet|\
ksh|\
light-mode|link|load|lucid|\
make|multisrc|mv|nocd|nocompile|nocompletions|notify|null|\
on-update-of|opts|\
pack|param|pick|proto|ps-on-unload|ps-on-update|pullopts|\
reset|reset-prompt|run-atpull|\
service|sh|silent|src|subscribe|subst|svn|\
teleid|trackbinds|trigger-load|\
unload|\
ver|verbose|\
wait|wrap"
ZINIT[nval-ice-list]="\
\!bash|\!csh|\!ksh|\!sh|\
aliases|\
bash|binary|blockf|\
cloneonly|cloneopts|cmake|configure|countdown|csh|\
debug|\
git|\
is-snippet|\
ksh|\
light-mode|lucid|\
make|\
nocd|nocompile|nocompletions|notify|null|\
pullopts|\
reset|run-atpull|\
sh|silent|\
trackbinds|\
verbose"
ZINIT[cmds]="\
add-fpath|\
bindkeys|\
cclear|cd|cdclear|cdisable|cdlist|cdreplay|cenable|changes|compile|compiled|compinit|completions|create|creinstall|csearch|cuninstall|\
delete|debug|\
edit|env-whitelist|\
fpath|\
glance|\
help|--help|-h|\
ice|\
light|load|\
man|module|\
plugins|\
recall|recently|report|run|\
self-update|snippet|snippets|srv|status|stress|\
times|\
uncompile|unload|update|\
version|\
zstatus"

# Can be customized.
: ${ZINIT[COMPLETIONS_DIR]:=${ZINIT[HOME_DIR]}/completions}
: ${ZINIT[MODULE_DIR]:=${ZINIT[HOME_DIR]}/module}
: ${ZINIT[PACKAGES_BRANCH]:=HEAD}
: ${ZINIT[PACKAGES_REPO]:=zdharma-continuum/zinit-packages}
: ${ZINIT[PLUGINS_DIR]:=${ZINIT[HOME_DIR]}/plugins}
: ${ZINIT[POLARIS_DIR]:=${ZINIT[HOME_DIR]}/polaris}
: ${ZINIT[SERVICES_DIR]:=${ZINIT[HOME_DIR]}/services}
: ${ZINIT[SNIPPETS_DIR]:=${ZINIT[HOME_DIR]}/snippets}
: ${ZINIT[ZPFX]:=${ZINIT[HOME_DIR]}/polaris}
typeset -g ZPFX
: ${ZPFX:=${ZINIT[ZPFX]}}
: ${ZINIT[ALIASES_OPT]::=${${options[aliases]:#off}:+1}}
: ${ZINIT[MAN_DIR]:=${ZPFX}/man}

ZINIT[PLUGINS_DIR]=${~ZINIT[PLUGINS_DIR]}   ZINIT[COMPLETIONS_DIR]=${~ZINIT[COMPLETIONS_DIR]}
ZINIT[SNIPPETS_DIR]=${~ZINIT[SNIPPETS_DIR]} ZINIT[SERVICES_DIR]=${~ZINIT[SERVICES_DIR]}

# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
  ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/zinit"
fi

export ZPFX=${~ZPFX} ZSH_CACHE_DIR="${ZSH_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/zinit}" \
    PMSPEC=0uUpiPsf
[[ -z ${path[(re)$ZPFX/bin]} ]] && [[ -d "$ZPFX/bin" ]] && path=( "$ZPFX/bin" "${path[@]}" )
[[ -z ${path[(re)$ZPFX/sbin]} ]] && [[ -d "$ZPFX/sbin" ]] && path=( "$ZPFX/sbin" "${path[@]}" )

hash -f
hash -d zinit=${ZINIT[HOME_DIR]}
hash -d plugins=${ZINIT[PLUGINS_DIR]}
hash -d zpfx=${ZINIT[HOME_DIR]}/polaris

# Add completions directory to fpath.
[[ -z ${fpath[(re)${ZINIT[COMPLETIONS_DIR]}]} ]] && fpath=( "${ZINIT[COMPLETIONS_DIR]}" "${fpath[@]}" )

[[ ! -d $ZSH_CACHE_DIR ]] && command mkdir -p "$ZSH_CACHE_DIR"
[[ -n ${ZINIT[ZCOMPDUMP_PATH]} ]] && ZINIT[ZCOMPDUMP_PATH]=${~ZINIT[ZCOMPDUMP_PATH]}

# Create "$ZSH_CACHE_DIR/completions" directory
[[ ! -d "$ZSH_CACHE_DIR/completions" ]] && command mkdir -p "$ZSH_CACHE_DIR/completions"
# Add "$ZSH_CACHE_DIR/completions" diretory to fpath
[[ -z ${fpath[(re)$ZSH_CACHE_DIR/completions]} ]] && fpath=( "$ZSH_CACHE_DIR/completions" "${fpath[@]}" )

ZINIT[UPAR]=";:^[[A;:^[OA;:\\e[A;:\\eOA;:${termcap[ku]/$'\e'/^\[};:${terminfo[kcuu1]/$'\e'/^\[};:"
ZINIT[DOWNAR]=";:^[[B;:^[OB;:\\e[B;:\\eOB;:${termcap[kd]/$'\e'/^\[};:${terminfo[kcud1]/$'\e'/^\[};:"
ZINIT[RIGHTAR]=";:^[[C;:^[OC;:\\e[C;:\\eOC;:${termcap[kr]/$'\e'/^\[};:${terminfo[kcuf1]/$'\e'/^\[};:"
ZINIT[LEFTAR]=";:^[[D;:^[OD;:\\e[D;:\\eOD;:${termcap[kl]/$'\e'/^\[};:${terminfo[kcub1]/$'\e'/^\[};:"

builtin autoload -Uz is-at-least
is-at-least 5.1 && ZINIT[NEW_AUTOLOAD]=1 || ZINIT[NEW_AUTOLOAD]=0
#is-at-least 5.4 && ZINIT[NEW_AUTOLOAD]=2

# Parameters [[[
# temporary substituting of functions
ZINIT[TMP_SUBST]=inactive ZINIT[DTRACE]=0 ZINIT[CUR_PLUGIN]=

# ice
declare -gA ZINIT_1MAP ZINIT_2MAP
ZINIT_1MAP=(
    OMZ:: https://github.com/ohmyzsh/ohmyzsh/trunk/
    OMZP:: https://github.com/ohmyzsh/ohmyzsh/trunk/plugins/
    OMZT:: https://github.com/ohmyzsh/ohmyzsh/trunk/themes/
    OMZL:: https://github.com/ohmyzsh/ohmyzsh/trunk/lib/
    PZT:: https://github.com/sorin-ionescu/prezto/trunk/
    PZTM:: https://github.com/sorin-ionescu/prezto/trunk/modules/
)
ZINIT_2MAP=(
    OMZ:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/
    OMZP:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/
    OMZT:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/themes/
    OMZL:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/lib/
    PZT:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/
    PZTM:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/modules/
)
# ]]]

# Init [[[
zmodload zsh/zutil || { builtin print -P "%F{196}zsh/zutil module is required, aborting Zinit set up.%f"; return 1; }
zmodload zsh/parameter || { builtin print -P "%F{196}zsh/parameter module is required, aborting Zinit set up.%f"; return 1; }
zmodload zsh/term{cap,info} 2>/dev/null
autoload -Uz colors && colors

if [[ -z $SOURCED && ( ${+terminfo} -eq 1 && -n ${terminfo[colors]} ) || ( ${+termcap} -eq 1 && -n ${termcap[Co]} ) ]]; then
  ZINIT+=(
    col-annex   $'\e[38;5;153m'         col-faint   $'\e[38;5;238m'         col-msg2    $'\e[38;5;172m'      col-quo     $'\e[1;38;5;33m'
    col-apo     $'\e[1;38;5;45m'        col-file    $'\e[3;38;5;117m'       col-msg3    $'\e[38;5;238m'      col-quos    $'\e[1;38;5;160m'
    col-aps     $'\e[38;5;117m'         col-flag    $'\e[1;3;38;5;79m'      col-nb      $'\e[22m'            col-rst     $'\e[0m'
    col-b       $'\e[1m'                col-func    $'\e[38;5;219m'         col-nit     $'\e[23m'            col-slight  $'\e[38;5;230m'
    col-b-lhi   $'\e[1m\e[38;5;75m'     col-glob    $'\e[38;5;227m'         col-nl      $'\n'                col-st      $'\e[9m'
    col-b-warn  $'\e[1;38;5;214m'       col-happy   $'\e[1m\e[38;5;82m'     col-note    $'\e[38;5;148m'      col-tab     $' \t '
    col-bapo    $'\e[1;38;5;220m'       col-hi      $'\e[1m\e[38;5;183m'    col-nst     $'\e[29m'            col-term    $'\e[38;5;185m'
    col-baps    $'\e[1;38;5;82m'        col-ice     $'\e[38;5;39m'          col-nu      $'\e[24m'            col-th-bar  $'\e[38;5;82m'
    col-bar     $'\e[38;5;82m'          col-id-as   $'\e[4;38;5;220m'       col-num     $'\e[3;38;5;155m'    col-time    $'\e[38;5;220m'
    col-bcmd    $'\e[38;5;220m'         col-info    $'\e[38;5;82m'          col-obj     $'\e[38;5;218m'      col-txt     $'\e[38;5;254m'
    col-bspc    $'\b'                   col-info2   $'\e[38;5;227m'         col-obj2    $'\e[38;5;118m'      col-u       $'\e[4m'
    col-cmd     $'\e[38;5;82m'          col-info3   $'\e[1m\e[38;5;227m'    col-ok      $'\e[38;5;220m'      col-u-warn  $'\e[4;38;5;214m'
    col-data    $'\e[38;5;82m'          col-it      $'\e[3m'                col-opt     $'\e[38;5;219m'      col-uname   $'\e[1;4m\e[35m'
    col-data2   $'\e[38;5;117m'         col-keyword $'\e[32m'               col-p       $'\e[38;5;81m'       col-uninst  $'\e[38;5;118m'
    col-dir     $'\e[3;38;5;153m'       col-lhi     $'\e[38;5;81m'          col-pkg     $'\e[1;3;38;5;27m'   col-url     $'\e[38;5;75m'
    col-ehi     $'\e[1m\e[38;5;210m'    col-meta    $'\e[38;5;57m'          col-pname   $'\e[1;4m\e[32m'     col-var     $'\e[38;5;81m'
    col-error   $'\e[1m\e[38;5;204m'    col-meta2   $'\e[38;5;147m'         col-pre     $'\e[38;5;135m'      col-version $'\e[3;38;5;87m'
    col-failure $'\e[38;5;204m'         col-msg     $'\e[0m'                col-profile $'\e[38;5;148m'      col-warn    $'\e[38;5;214m'

    col-dbg $'\e[2m\e[38;47;107m'"[debug]"$'\e[0m'
    col-e $'\e[1m\e[38;5;204m'"Error"$'\e[0m'":"
    col-i $'\e[1m\e[38;5;82m'"==>"$'\e[0m'
    col-m $'\e[38;5;4m'"==>"$'\e[0m'
    col-w $'\e[1m\e[38;5;214m'"Warning"$'\e[0m'":"

    col--…   "${${${(M)LANG:#*UTF-8*}:+⋯⋯}:-···}"    col-lr "${${${(M)LANG:#*UTF-8*}:+↔}:-"«-»"}"
    col-ndsh "${${${(M)LANG:#*UTF-8*}:+–}:-}"        col-…  "${${${(M)LANG:#*UTF-8*}:+…}:-...}"

    col-mdsh  $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+–}:--}"$'\e[0m'
    col-mmdsh $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+――}:--}"$'\e[0m'

    col-↔     ${${${(M)LANG:#*UTF-8*}:+$'\e[38;5;82m↔\e[0m'}:-$'\e[38;5;82m«-»\e[0m'}
  )
  if [[ ( ${+terminfo} -eq 1 && ${terminfo[colors]} -ge 256 ) || ( ${+termcap} -eq 1 && ${termcap[Co]} -ge 256 ) ]]; then
    ZINIT+=( col-pname $'\e[1;4m\e[38;5;39m' col-uname  $'\e[1;4m\e[38;5;207m' )
  fi
fi

# Hooks
typeset -gAH ZINIT_ZLE_HOOKS_LIST
ZINIT_ZLE_HOOKS_LIST=(
    zle-isearch-exit 1
    zle-isearch-update 1
    zle-line-pre-redraw 1
    zle-line-init 1
    zle-line-finish 1
    zle-history-line-set 1
    zle-keymap-select 1
    paste-insert 1
)
builtin setopt noaliases
# ]]]

#
# Temporary substituting of functions-related functions.
#

# FUNCTION: :zinit-reload-and-run [[[
# Marks given function ($3) for autoloading, and executes it triggering the
# load. $1 is the fpath dedicated to the function, $2 are autoload options.
# This function replaces "autoload -X", because using that on older Zsh
# versions causes problems with traps.
#
# So basically one creates function stub that calls :zinit-reload-and-run()
# instead of "autoload -X".
#
# Author: Bart Schaefer
#
# $1 - FPATH dedicated to function
# $2 - autoload options
# $3 - function name (one that needs autoloading)
:zinit-reload-and-run() {
    local fpath_prefix="$1" autoload_opts="$2" func="$3"
    shift 3

    # Unfunction caller function (its name is given).
    unfunction -- "$func"

    local -a ___fpath
    ___fpath=( ${fpath[@]} )
    local -a +h fpath
    # See #127.
    [[ $FPATH != *${${(@0)fpath_prefix}[1]}* ]] && \
        fpath=( ${(@0)fpath_prefix} ${___fpath[@]} )

    # After this the function exists again.
    builtin autoload ${(s: :)autoload_opts} -- "$func"

    # User wanted to call the function, not only load it.
    "$func" "$@"
} # ]]]
# FUNCTION: :zinit-tmp-subst-autoload [[[
# Hijack plugin's calls to the 'autoload' builtin.
#
# The hijacking gathers report data and runs custom `autoload' function, that doesn't need FPATH.
:zinit-tmp-subst-autoload() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt extendedglob warncreateglobal typesetsilent rcquotes
    local -a opts opts2 custom reply
    local func

    zparseopts -D -E -M -a opts ${(s::):-RTUXdkmrtWzwC} I+=opts2 S+:=custom

    builtin set -- ${@:#--}

    # Process the id-as''/teleid'' to get the plugin dir.
    .zinit-any-to-user-plugin $ZINIT[CUR_USPL2]
    [[ $reply[1] = % ]] && \
        local PLUGIN_DIR="$reply[2]" || \
        local PLUGIN_DIR="$ZINIT[PLUGINS_DIR]/${reply[1]:+$reply[1]---}${reply[2]//\//---}"


    # "fpath elements" ----  those elements that lie inside the plug directory.
    local -a fpath_elements
    fpath_elements=( ${fpath[(r)$PLUGIN_DIR/*]} )

    # Add a function subdirectory to items, if any (this action is
    # according to the Plug Standard version 1.07 and later).
    [[ -d $PLUGIN_DIR/functions ]] && fpath_elements+=( "$PLUGIN_DIR"/functions )

    if (( ${+opts[(r)-X]} )); then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: Failed autoload ${(j: :)opts[@]} $*"
        +zi-log -u2 "{error}builtin autoload required for {obj}${(j: :)opts[@]}{error} option(s)"
        return 1
    fi
    if (( ${+opts[(r)-w]} )); then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "-w-Autoload ${(j: :)opts[@]} ${(j: :)@}"
        fpath+=( $PLUGIN_DIR )
        builtin autoload ${opts[@]} "$@"
        return $?
    fi
    if [[ -n ${(M)@:#+X} ]]; then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Autoload +X ${opts:+${(j: :)opts[@]} }${(j: :)${@:#+X}}"
        local +h FPATH=$PLUGINS_DIR${fpath_elements:+:${(j.:.)fpath_elements[@]}}:$FPATH
        local +h -a fpath
        fpath=( $PLUGIN_DIR $fpath_elements $fpath )
        builtin autoload +X ${opts[@]} "${@:#+X}"
        return $?
    fi

    for func; do
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Autoload $func${opts:+ with options ${(j: :)opts[@]}}"
    done

    integer count retval
    for func; do
        # Real autoload doesn't touch function if it already exists.
        # Author of the idea of FPATH-clean autoloading: Bart Schaefer.
        if (( ${+functions[$func]} != 1 )) {
            builtin setopt noaliases
            if [[ $func == /* ]] && is-at-least 5.4; then
                builtin autoload ${opts[@]} $func
                return $?
            elif [[ $func == /* ]]; then
                if [[ $ZINIT[MUTE_WARNINGS] != (1|true|on|yes) && \
                        -z $ZINIT[WARN_SHOWN_FOR_$ZINIT[CUR_USPL2]] ]]; then
                    +zi-log "{u-warn}Warning{b-warn}: {rst}the plugin {pid}$ZINIT[CUR_USPL2]" \
                        "{rst}is using autoload functions specified by their absolute path," \
                        "which is not supported by this Zsh version ({↔} {version}$ZSH_VERSION{rst}," \
                        "required is Zsh >= {version}5.4{rst})." \
                        "{nl}A fallback mechanism has been applied, which works well only" \
                        "for functions in the plugin {u}{slight}main{rst} directory." \
                        "{nl}(To mute this message, set" \
                        "{var}\$ZINIT[MUTE_WARNINGS]{rst} to a truth value.)"
                    ZINIT[WARN_SHOWN_FOR_$ZINIT[CUR_USPL2]]=1
                fi

                # Workaround
                func=$func:t
            fi
            if [[ ${ZINIT[NEW_AUTOLOAD]} = 2 ]]; then
                builtin autoload ${opts[@]} "$PLUGIN_DIR/$func"
                retval=$?
            elif [[ ${ZINIT[NEW_AUTOLOAD]} = 1 ]]; then
                if (( ${+opts[(r)-C]} )) {
                    local pth nl=$'\n' sel=""
                    for pth ( $PLUGIN_DIR $fpath_elements $fpath ) {
                        [[ -f $pth/$func ]] && { sel=$pth; break; }
                    }
                    if [[ -z $sel ]] {
                        +zi-log '{u-warn}zinit{b-warn}:{error} Couldn''t find autoload function{ehi}:' \
                            "{apo}\`{file}${func}{apo}\`{error} anywhere in {var}\$fpath{error}."
                            retval=1
                    } else {
                        eval "function ${(q)${custom[++count*2]}:-$func} {
                            local body=\"\$(<${(qqq)sel}/${(qqq)func})\" body2
                            () { setopt localoptions extendedglob
                                 body2=\"\${body##[[:space:]]#${func}[[:blank:]]#\(\)[[:space:]]#\{}\"
                                 [[ \$body2 != \$body ]] && \
                                    body2=\"\${body2%\}[[:space:]]#([$nl]#([[:blank:]]#\#[^$nl]#((#e)|[$nl]))#)#}\"
                            }

                            functions[${${(q)custom[count*2]}:-$func}]=\"\$body2\"
                            ${(q)${custom[count*2]}:-$func} \"\$@\"
                        }"
                        retval=$?
                    }
                } else {
                    functions[$func]="
                        local -a fpath
                        fpath=( ${(qqq)PLUGIN_DIR} ${(qqq@)fpath_elements} ${(qqq@)fpath} )
                        builtin autoload -X ${(j: :)${(q-)opts[@]}}
                    "
                    retval=$?
                }
            else
                eval "function ${(q)func} {
                    :zinit-reload-and-run ${(qqq)PLUGIN_DIR}"$'\0'"${(pj,\0,)${(qqq)fpath_elements[@]}} ${(qq)opts[*]} ${(q)func} "'"$@"
                }'
                retval=$?
            fi
            (( ZINIT[ALIASES_OPT] )) && builtin setopt aliases
        }
        if (( ${+opts2[(r)-I]} )) {
            ${custom[count*2]:-$func}
            retval=$?
        }
    done

    return $retval
} # ]]]
# FUNCTION: :zinit-tmp-subst-bindkey [[[
# Function defined to hijack plugin's calls to the `bindkey' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-bindkey() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt extendedglob warncreateglobal typesetsilent noshortloops

    is-at-least 5.3 && \
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Bindkey ${(j: :)${(q+)@}}" || \
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Bindkey ${(j: :)${(q)@}}"

    # Remember to perform the actual bindkey call.
    typeset -a pos
    pos=( "$@" )

    # Check if we have regular bindkey call, i.e.
    # with no options or with -s, plus possible -M
    # option.
    local -A opts
    zparseopts -A opts -D ${(s::):-lLdDAmrsevaR} M: N:

    if (( ${#opts} == 0 ||
        ( ${#opts} == 1 && ${+opts[-M]} ) ||
        ( ${#opts} == 1 && ${+opts[-R]} ) ||
        ( ${#opts} == 1 && ${+opts[-s]} ) ||
        ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-s]} ) ||
        ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-R]} )
    )); then
        local string="${(q)1}" widget="${(q)2}"
        local quoted

        if [[ -n ${ICE[bindmap]} && ${ZINIT_CUR_BIND_MAP[empty]} -eq 1 ]]; then
            local -a pairs
            pairs=( "${(@s,;,)ICE[bindmap]}" )
            if [[ -n ${(M)pairs:#*\\(#e)} ]] {
                local prev
                pairs=( ${pairs[@]//(#b)((*)\\(#e)|(*))/${match[3]:+${prev:+$prev\;}}${match[3]}${${prev::=${match[2]:+${prev:+$prev\;}}${match[2]}}:+}} )
            }
            pairs=( "${(@)${(@)${(@s:->:)pairs}##[[:space:]]##}%%[[:space:]]##}" )
            ZINIT_CUR_BIND_MAP=( empty 0 )
            (( ${#pairs} > 1 && ${#pairs[@]} % 2 == 0 )) && ZINIT_CUR_BIND_MAP+=( "${pairs[@]}" )
        fi

        local bmap_val="${ZINIT_CUR_BIND_MAP[${1}]}"
        if (( !ZINIT_CUR_BIND_MAP[empty] )) {
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[${(qqq)1}]}"
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[${(qqq)${(Q)1}}]}"
            [[ -z $bmap_val ]] && { bmap_val="${ZINIT_CUR_BIND_MAP[!${(qqq)1}]}"; integer val=1; }
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[!${(qqq)${(Q)1}}]}"
        }
        if [[ -n $bmap_val ]]; then
            string="${(q)bmap_val}"
            if (( val )) {
                [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
            } else {
                [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
            }
            .zinit-add-report "${ZINIT[CUR_USPL2]}" ":::Bindkey: combination <$1> changed to <$bmap_val>${${(M)bmap_val:#hold}:+, i.e. ${ZINIT[col-error]}unmapped${ZINIT[col-rst]}}"
            ((1))
        elif [[ ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[UPAR]}} && -n ${${ZINIT[UPAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[DOWNAR]}} && -n ${${ZINIT[DOWNAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[RIGHTAR]}} && -n ${${ZINIT[RIGHTAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[LEFTAR]}} && -n ${${ZINIT[LEFTAR]}[(r);:${(q)1};:]} )
        ]]; then
            string="${(q)bmap_val}"
            if (( val )) {
                [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
            } else {
                [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
            }
            .zinit-add-report "${ZINIT[CUR_USPL2]}" ":::Bindkey: combination <$1> recognized as cursor-key and changed to <${bmap_val}>${${(M)bmap_val:#hold}:+, i.e. ${ZINIT[col-error]}unmapped${ZINIT[col-rst]}}"
        fi
        [[ $bmap_val = hold ]] && return 0

        local prev="${(q)${(s: :)$(builtin bindkey ${(Q)string})}[-1]#undefined-key}"

        # "-M map" given?
        if (( ${+opts[-M]} )); then
            local Mopt=-M
            local Marg="${opts[-M]}"

            Mopt="${(q)Mopt}"
            Marg="${(q)Marg}"

            quoted="$string $widget $prev $Mopt $Marg"
        else
            quoted="$string $widget $prev"
        fi

        # -R given?
        if (( ${+opts[-R]} )); then
            local Ropt=-R
            Ropt="${(q)Ropt}"

            if (( ${+opts[-M]} )); then
                quoted="$quoted $Ropt"
            else
                # Two empty fields for non-existent -M arg.
                local space=_
                space="${(q)space}"
                quoted="$quoted $space $space $Ropt"
            fi
        fi

        quoted="${(q)quoted}"

        # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "
    else
        # bindkey -A newkeymap main?
        # Negative indices for KSH_ARRAYS immunity.
        if [[ ${#opts} -eq 1 && ${+opts[-A]} = 1 && ${#pos} = 3 && ${pos[-1]} = main && ${pos[-2]} != -A ]]; then
            # Save a copy of main keymap.
            (( ZINIT[BINDKEY_MAIN_IDX] = ${ZINIT[BINDKEY_MAIN_IDX]:-0} + 1 ))
            local pname="${ZINIT[CUR_PLUGIN]:-_dtrace}"
            local name="${(q)pname}-main-${ZINIT[BINDKEY_MAIN_IDX]}"
            builtin bindkey -N "$name" main

            # Remember occurence of main keymap substitution, to revert on unload.
            local keys=_ widget=_ prev= optA=-A mapname="${name}" optR=_
            local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optA} ${(q)mapname} ${(q)optR}"
            quoted="${(q)quoted}"

            # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
            [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
            [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "

            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: keymap \`main' copied to \`${name}' because of \`${pos[-2]}' substitution"
        # bindkey -N newkeymap [other].
        elif [[ ${#opts} -eq 1 && ${+opts[-N]} = 1 ]]; then
            local Nopt=-N
            local Narg="${opts[-N]}"

            local keys=_ widget=_ prev= optN=-N mapname="${Narg}" optR=_
            local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optN} ${(q)mapname} ${(q)optR}"
            quoted="${(q)quoted}"

            # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
            [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
            [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "
        else
            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: last bindkey used non-typical options: ${(kv)opts[*]}"
        fi
    fi

    # Actual bindkey.
    builtin bindkey "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-zstyle [[[
# Function defined to hijack plugin's calls to the `zstyle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-zstyle() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob nowarncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Zstyle $*"

    # Remember in order to perform the actual zstyle call.
    typeset -a pos
    pos=( "$@" )

    # Check if we have regular zstyle call, i.e.
    # with no options or with -e.
    local -a opts
    zparseopts -a opts -D ${(s::):-eLdgabsTtm}

    if [[ ${#opts} -eq 0 || ( ${#opts} -eq 1 && ${+opts[(r)-e]} = 1 ) ]]; then
        # Have to quote $1, then $2, then concatenate them, then quote them again.
        local pattern="${(q)1}" style="${(q)2}"
        local ps="$pattern $style"
        ps="${(q)ps}"

        # Remember the zstyle, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[ZSTYLES__${ZINIT[CUR_USPL2]}]+="$ps "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[ZSTYLES___dtrace/_dtrace]+=$ps
    else
        if [[ ! ${#opts[@]} = 1 && ( ${+opts[(r)-s]} = 1 || ${+opts[(r)-b]} = 1 || ${+opts[(r)-a]} = 1 ||
              ${+opts[(r)-t]} = 1 || ${+opts[(r)-T]} = 1 || ${+opts[(r)-m]} = 1 )
        ]]; then
            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: last zstyle used non-typical options: ${opts[*]}"
        fi
    fi

    # Actual zstyle.
    builtin zstyle "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-alias [[[
# Function defined to hijack plugin's calls to the `alias' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-alias() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Alias $*"

    # Remember to perform the actual alias call.
    typeset -a pos
    pos=( "$@" )

    local -a opts
    zparseopts -a opts -D ${(s::):-gs}

    local a quoted tmp
    for a in "$@"; do
        local aname="${a%%[=]*}"
        local avalue="${a#*=}"

        # Check if alias is to be redefined.
        (( ${+aliases[$aname]} )) && .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: redefining alias \`${aname}', previous value: ${aliases[$aname]}"

        local bname=${(q)aliases[$aname]}
        aname="${(q)aname}"

        if (( ${+opts[(r)-s]} )); then
            tmp=-s
            tmp="${(q)tmp}"
            quoted="$aname $bname $tmp"
        elif (( ${+opts[(r)-g]} )); then
            tmp=-g
            tmp="${(q)tmp}"
            quoted="$aname $bname $tmp"
        else
            quoted="$aname $bname"
        fi

        quoted="${(q)quoted}"

        # Remember the alias, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[ALIASES__${ZINIT[CUR_USPL2]}]+="$quoted "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[ALIASES___dtrace/_dtrace]+="$quoted "
    done

    # Actual alias.
    builtin alias "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-zle [[[.
# Function defined to hijack plugin's calls to the `zle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-zle() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Zle $*"

    # Remember to perform the actual zle call.
    typeset -a pos
    pos=( "$@" )

    builtin set -- "${@:#--}"

    # Try to catch game-changing "-N".
    if [[ ( $1 = -N && ( $# = 2 || $# = 3 ) ) || ( $1 = -C && $# = 4 ) ]]; then
            # Hooks.
            if [[ ${ZINIT_ZLE_HOOKS_LIST[$2]} = 1 ]]; then
                local quoted="$2"
                quoted="${(q)quoted}"
                # Remember only when load is in progress (it can be dstart that leads execution here).
                [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_DELETE__${ZINIT[CUR_USPL2]}]+="$quoted "
                # Remember for dtrace.
                [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
            # These will be saved and restored.
            elif (( ${+widgets[$2]} )); then
                # Have to remember original widget "$2" and
                # the copy that it's going to be done.
                local widname="$2" targetfun="${${${(M)1:#-C}:+$4}:-$3}"
                local completion_widget="${${(M)1:#-C}:+$3}"
                local saved_widcontents="${widgets[$widname]}"

                widname="${(q)widname}"
                completion_widget="${(q)completion_widget}"
                targetfun="${(q)targetfun}"
                saved_widcontents="${(q)saved_widcontents}"
                local quoted="$1 $widname $completion_widget $targetfun $saved_widcontents"
                quoted="${(q)quoted}"
                # Remember only when load is in progress (it can be dstart that leads execution here).
                [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_SAVED__${ZINIT[CUR_USPL2]}]+="$quoted "
                # Remember for dtrace.
                [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_SAVED___dtrace/_dtrace]+="$quoted "
             # These will be deleted.
             else
                 .zinit-add-report "${ZINIT[CUR_USPL2]}" "Note: a new widget created via zle -N: \`$2'"
                 local quoted="$2"
                 quoted="${(q)quoted}"
                 # Remember only when load is in progress (it can be dstart that leads execution here).
                 [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_DELETE__${ZINIT[CUR_USPL2]}]+="$quoted "
                 # Remember for dtrace.
                 [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
             fi
    fi

    # Actual zle.
    builtin zle "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-compdef [[[
# Function defined to hijack plugin's calls to the `compdef' function.
# The hijacking is not only for reporting, but also to save compdef
# calls so that `compinit' can be called after loading plugins.
:zinit-tmp-subst-compdef() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Saving \`compdef $*' for replay"
    ZINIT_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" )

    return 0 # testable
} # ]]]
# FUNCTION: .zinit-tmp-subst-on [[[
# Turn on temporary substituting of functions of builtins and functions according to passed
# mode ("load", "light", "light-b" or "compdef"). The temporary substituting of functions is
# to gather report data, and to hijack 'autoload', 'bindkey' and 'compdef' calls.
.zinit-tmp-subst-on() {
    local mode="$1"

    # Enable temporary substituting of functions only once.
    #
    # One could expect possibility of widening of temporary substituting of functions, however
    # such sequence doesn't exist, e.g. "light" then "load"/"dtrace", "compdef" then "load"/
    # "dtrace", "light" then "compdef", "compdef" then "light".
    #
    # It is always "dtrace" then "load" (i.e. dtrace then load) "dtrace" then "light" (i.e.:
    # dtrace then light load) "dtrace" then "compdef" (i.e.: dtrace then snippet).
    [[ ${ZINIT[TMP_SUBST]} != inactive ]] && builtin return 0

    ZINIT[TMP_SUBST]="$mode"

    # The point about backuping is: does the key exist in functions array.
    # If it does exist, then it will also exist as ZINIT[bkp-*].

    # Defensive code, shouldn't be needed.
    builtin unset "ZINIT[bkp-autoload]" "ZINIT[bkp-compdef]"  # 0, E.

    if [[ $mode != compdef ]]; then
        # 0. Used, but not in temporary restoration, which doesn't happen for autoload.
        (( ${+functions[autoload]} )) && ZINIT[bkp-autoload]="${functions[autoload]}"
        functions[autoload]=':zinit-tmp-subst-autoload "$@";'
    fi

    # E. Always shade compdef.
    (( ${+functions[compdef]} )) && ZINIT[bkp-compdef]="${functions[compdef]}"
    functions[compdef]=':zinit-tmp-subst-compdef "$@";'

    # Temporarily replace `source' if subst'' given.
    if [[ -n ${ICE[subst]} ]] {
        (( ${+functions[source]} )) && ZINIT[bkp-source]="${functions[source]}"
        (( ${+functions[.]} )) && ZINIT[bkp-.]="${functions[.]}"
        (( ${+functions[.zinit-service]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-additional.zsh"
        functions[source]=':zinit-tmp-subst-source "$@";'
        functions[.]=':zinit-tmp-subst-source "$@";'
    }

    # Light and compdef temporary substituting of functions stops here. Dtrace and load go on.
    [[ ( $mode = light && ${+ICE[trackbinds]} -eq 0 ) || $mode = compdef ]] && return 0
... truncated; 2,551 more lines
.claude/worktrees/agent-ab18cfe51348871be/tests/recorder_corpus/zinit/zinit.zsh — 3,351 LOC
#
# zdharma-continuum/zinit/zinit.zsh
# Copyright (c) 2016-2021 Sebastian Gniazdowski
# Copyright (c) 2021-2023 zdharma-continuum
# Homepage: https://github.com/zdharma-continuum/zinit
# License: MIT License
#

#
# Main state variables.
#

typeset -gaH ZINIT_REGISTERED_PLUGINS ZINIT_TASKS ZINIT_RUN
typeset -ga zsh_loaded_plugins
if (( !${#ZINIT_TASKS} )) { ZINIT_TASKS=( "<no-data>" ); }
# Snippets loaded, url -> file name.
typeset -gAH ZINIT ZINIT_SNIPPETS ZINIT_REPORTS ZINIT_ICES ZINIT_SICE ZINIT_CUR_BIND_MAP ZINIT_EXTS ZINIT_EXTS2
typeset -gaH ZINIT_COMPDEF_REPLAY

# Compatibility with pre-rename project (Zplugin).
typeset -gAH ZPLGM
ZINIT=( "${(kv)ZPLGM[@]}" "${(kv)ZINIT[@]}" )
unset ZPLGM

#
# Common needed values.
#

[[ ! -e ${ZINIT[BIN_DIR]}/zinit.zsh ]] && ZINIT[BIN_DIR]=

# Respect the plugin standard too.
ZINIT[ZERO]="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
[[ ! -o functionargzero || ${options[posixargzero]} = on || ${ZINIT[ZERO]} != */* ]] && ZINIT[ZERO]="${(%):-%N}"

: ${ZINIT[BIN_DIR]:="${ZINIT[ZERO]:h}"}
[[ ${ZINIT[BIN_DIR]} = \~* ]] && ZINIT[BIN_DIR]=${~ZINIT[BIN_DIR]}

# Make ZINIT[BIN_DIR] path absolute.
ZINIT[BIN_DIR]="${${(M)ZINIT[BIN_DIR]:#/*}:-$PWD/${ZINIT[BIN_DIR]}}"

# Final test of ZINIT[BIN_DIR].
if [[ ! -e ${ZINIT[BIN_DIR]}/zinit.zsh ]]; then
    builtin print -P "%F{196}Could not establish ZINIT[BIN_DIR] hash field. It should point where Zinit's Git repository is.%f"
    return 1
fi

# User can override ZINIT[HOME_DIR].
if [[ -z ${ZINIT[HOME_DIR]} ]]; then
    # Search for zinit home in the usual locations
    if [[ -d ${XDG_DATA_HOME:-${HOME}/.local/share}/zinit ]]; then
        ZINIT[HOME_DIR]="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
    elif [[ -d $HOME/.zinit ]]; then
        ZINIT[HOME_DIR]="$HOME/.zinit"
    elif [[ -d ${ZDOTDIR:-$HOME}/.zinit ]]; then
        ZINIT[HOME_DIR]="${ZDOTDIR:-$HOME}/.zinit"
    elif [[ -d $HOME/.zplugin ]]; then
        ZINIT[HOME_DIR]="$HOME/.zplugin"
    elif [[ -d ${ZDOTDIR:-$HOME}/.zplugin ]]; then
        ZINIT[HOME_DIR]="${ZDOTDIR:-$HOME}/.zplugin"
    else
        ZINIT[HOME_DIR]="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
    fi
fi

if [[ -z ${ZINIT[LIST_COMMAND]} ]]; then
    if (( ${+commands[eza]} )); then
        ZINIT[LIST_COMMAND]='eza --color=always --tree --icons -L3'
    elif (( ${+commands[exa]} )); then
        ZINIT[LIST_COMMAND]='exa --color=always --tree --icons -L3'
    elif (( ${+commands[tree]} )); then
        ZINIT[LIST_COMMAND]='tree -L 3 -C --charset utf-8'
    else
        ZINIT[LIST_COMMAND]='ls --tree'
    fi
fi

ZINIT[ice-list]="\
\!bash|\!csh|\!ksh|\!sh|\
aliases|as|atclone|atdelete|atinit|atload|atpull|autoload|\
bash|binary|bindmap|blockf|bpick|build|\
cloneonly|cloneopts|cmake|compile|completions|configure|countdown|cp|csh|\
debug|depth|\
extract|\
from|git|\
has|\
id-as|if|install|is-snippet|\
ksh|\
light-mode|link|load|lucid|\
make|multisrc|mv|nocd|nocompile|nocompletions|notify|null|\
on-update-of|opts|\
pack|param|pick|proto|ps-on-unload|ps-on-update|pullopts|\
reset|reset-prompt|run-atpull|\
service|sh|silent|src|subscribe|subst|svn|\
teleid|trackbinds|trigger-load|\
unload|\
ver|verbose|\
wait|wrap"
ZINIT[nval-ice-list]="\
\!bash|\!csh|\!ksh|\!sh|\
aliases|\
bash|binary|blockf|\
cloneonly|cloneopts|cmake|configure|countdown|csh|\
debug|\
git|\
is-snippet|\
ksh|\
light-mode|lucid|\
make|\
nocd|nocompile|nocompletions|notify|null|\
pullopts|\
reset|run-atpull|\
sh|silent|\
trackbinds|\
verbose"
ZINIT[cmds]="\
add-fpath|\
bindkeys|\
cclear|cd|cdclear|cdisable|cdlist|cdreplay|cenable|changes|compile|compiled|compinit|completions|create|creinstall|csearch|cuninstall|\
delete|debug|\
edit|env-whitelist|\
fpath|\
glance|\
help|--help|-h|\
ice|\
light|load|\
man|module|\
plugins|\
recall|recently|report|run|\
self-update|snippet|snippets|srv|status|stress|\
times|\
uncompile|unload|update|\
version|\
zstatus"

# Can be customized.
: ${ZINIT[COMPLETIONS_DIR]:=${ZINIT[HOME_DIR]}/completions}
: ${ZINIT[MODULE_DIR]:=${ZINIT[HOME_DIR]}/module}
: ${ZINIT[PACKAGES_BRANCH]:=HEAD}
: ${ZINIT[PACKAGES_REPO]:=zdharma-continuum/zinit-packages}
: ${ZINIT[PLUGINS_DIR]:=${ZINIT[HOME_DIR]}/plugins}
: ${ZINIT[POLARIS_DIR]:=${ZINIT[HOME_DIR]}/polaris}
: ${ZINIT[SERVICES_DIR]:=${ZINIT[HOME_DIR]}/services}
: ${ZINIT[SNIPPETS_DIR]:=${ZINIT[HOME_DIR]}/snippets}
: ${ZINIT[ZPFX]:=${ZINIT[HOME_DIR]}/polaris}
typeset -g ZPFX
: ${ZPFX:=${ZINIT[ZPFX]}}
: ${ZINIT[ALIASES_OPT]::=${${options[aliases]:#off}:+1}}
: ${ZINIT[MAN_DIR]:=${ZPFX}/man}

ZINIT[PLUGINS_DIR]=${~ZINIT[PLUGINS_DIR]}   ZINIT[COMPLETIONS_DIR]=${~ZINIT[COMPLETIONS_DIR]}
ZINIT[SNIPPETS_DIR]=${~ZINIT[SNIPPETS_DIR]} ZINIT[SERVICES_DIR]=${~ZINIT[SERVICES_DIR]}

# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
  ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/zinit"
fi

export ZPFX=${~ZPFX} ZSH_CACHE_DIR="${ZSH_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/zinit}" \
    PMSPEC=0uUpiPsf
[[ -z ${path[(re)$ZPFX/bin]} ]] && [[ -d "$ZPFX/bin" ]] && path=( "$ZPFX/bin" "${path[@]}" )
[[ -z ${path[(re)$ZPFX/sbin]} ]] && [[ -d "$ZPFX/sbin" ]] && path=( "$ZPFX/sbin" "${path[@]}" )

hash -f
hash -d zinit=${ZINIT[HOME_DIR]}
hash -d plugins=${ZINIT[PLUGINS_DIR]}
hash -d zpfx=${ZINIT[HOME_DIR]}/polaris

# Add completions directory to fpath.
[[ -z ${fpath[(re)${ZINIT[COMPLETIONS_DIR]}]} ]] && fpath=( "${ZINIT[COMPLETIONS_DIR]}" "${fpath[@]}" )

[[ ! -d $ZSH_CACHE_DIR ]] && command mkdir -p "$ZSH_CACHE_DIR"
[[ -n ${ZINIT[ZCOMPDUMP_PATH]} ]] && ZINIT[ZCOMPDUMP_PATH]=${~ZINIT[ZCOMPDUMP_PATH]}

# Create "$ZSH_CACHE_DIR/completions" directory
[[ ! -d "$ZSH_CACHE_DIR/completions" ]] && command mkdir -p "$ZSH_CACHE_DIR/completions"
# Add "$ZSH_CACHE_DIR/completions" diretory to fpath
[[ -z ${fpath[(re)$ZSH_CACHE_DIR/completions]} ]] && fpath=( "$ZSH_CACHE_DIR/completions" "${fpath[@]}" )

ZINIT[UPAR]=";:^[[A;:^[OA;:\\e[A;:\\eOA;:${termcap[ku]/$'\e'/^\[};:${terminfo[kcuu1]/$'\e'/^\[};:"
ZINIT[DOWNAR]=";:^[[B;:^[OB;:\\e[B;:\\eOB;:${termcap[kd]/$'\e'/^\[};:${terminfo[kcud1]/$'\e'/^\[};:"
ZINIT[RIGHTAR]=";:^[[C;:^[OC;:\\e[C;:\\eOC;:${termcap[kr]/$'\e'/^\[};:${terminfo[kcuf1]/$'\e'/^\[};:"
ZINIT[LEFTAR]=";:^[[D;:^[OD;:\\e[D;:\\eOD;:${termcap[kl]/$'\e'/^\[};:${terminfo[kcub1]/$'\e'/^\[};:"

builtin autoload -Uz is-at-least
is-at-least 5.1 && ZINIT[NEW_AUTOLOAD]=1 || ZINIT[NEW_AUTOLOAD]=0
#is-at-least 5.4 && ZINIT[NEW_AUTOLOAD]=2

# Parameters [[[
# temporary substituting of functions
ZINIT[TMP_SUBST]=inactive ZINIT[DTRACE]=0 ZINIT[CUR_PLUGIN]=

# ice
declare -gA ZINIT_1MAP ZINIT_2MAP
ZINIT_1MAP=(
    OMZ:: https://github.com/ohmyzsh/ohmyzsh/trunk/
    OMZP:: https://github.com/ohmyzsh/ohmyzsh/trunk/plugins/
    OMZT:: https://github.com/ohmyzsh/ohmyzsh/trunk/themes/
    OMZL:: https://github.com/ohmyzsh/ohmyzsh/trunk/lib/
    PZT:: https://github.com/sorin-ionescu/prezto/trunk/
    PZTM:: https://github.com/sorin-ionescu/prezto/trunk/modules/
)
ZINIT_2MAP=(
    OMZ:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/
    OMZP:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/
    OMZT:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/themes/
    OMZL:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/lib/
    PZT:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/
    PZTM:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/modules/
)
# ]]]

# Init [[[
zmodload zsh/zutil || { builtin print -P "%F{196}zsh/zutil module is required, aborting Zinit set up.%f"; return 1; }
zmodload zsh/parameter || { builtin print -P "%F{196}zsh/parameter module is required, aborting Zinit set up.%f"; return 1; }
zmodload zsh/term{cap,info} 2>/dev/null
autoload -Uz colors && colors

if [[ -z $SOURCED && ( ${+terminfo} -eq 1 && -n ${terminfo[colors]} ) || ( ${+termcap} -eq 1 && -n ${termcap[Co]} ) ]]; then
  ZINIT+=(
    col-annex   $'\e[38;5;153m'         col-faint   $'\e[38;5;238m'         col-msg2    $'\e[38;5;172m'      col-quo     $'\e[1;38;5;33m'
    col-apo     $'\e[1;38;5;45m'        col-file    $'\e[3;38;5;117m'       col-msg3    $'\e[38;5;238m'      col-quos    $'\e[1;38;5;160m'
    col-aps     $'\e[38;5;117m'         col-flag    $'\e[1;3;38;5;79m'      col-nb      $'\e[22m'            col-rst     $'\e[0m'
    col-b       $'\e[1m'                col-func    $'\e[38;5;219m'         col-nit     $'\e[23m'            col-slight  $'\e[38;5;230m'
    col-b-lhi   $'\e[1m\e[38;5;75m'     col-glob    $'\e[38;5;227m'         col-nl      $'\n'                col-st      $'\e[9m'
    col-b-warn  $'\e[1;38;5;214m'       col-happy   $'\e[1m\e[38;5;82m'     col-note    $'\e[38;5;148m'      col-tab     $' \t '
    col-bapo    $'\e[1;38;5;220m'       col-hi      $'\e[1m\e[38;5;183m'    col-nst     $'\e[29m'            col-term    $'\e[38;5;185m'
    col-baps    $'\e[1;38;5;82m'        col-ice     $'\e[38;5;39m'          col-nu      $'\e[24m'            col-th-bar  $'\e[38;5;82m'
    col-bar     $'\e[38;5;82m'          col-id-as   $'\e[4;38;5;220m'       col-num     $'\e[3;38;5;155m'    col-time    $'\e[38;5;220m'
    col-bcmd    $'\e[38;5;220m'         col-info    $'\e[38;5;82m'          col-obj     $'\e[38;5;218m'      col-txt     $'\e[38;5;254m'
    col-bspc    $'\b'                   col-info2   $'\e[38;5;227m'         col-obj2    $'\e[38;5;118m'      col-u       $'\e[4m'
    col-cmd     $'\e[38;5;82m'          col-info3   $'\e[1m\e[38;5;227m'    col-ok      $'\e[38;5;220m'      col-u-warn  $'\e[4;38;5;214m'
    col-data    $'\e[38;5;82m'          col-it      $'\e[3m'                col-opt     $'\e[38;5;219m'      col-uname   $'\e[1;4m\e[35m'
    col-data2   $'\e[38;5;117m'         col-keyword $'\e[32m'               col-p       $'\e[38;5;81m'       col-uninst  $'\e[38;5;118m'
    col-dir     $'\e[3;38;5;153m'       col-lhi     $'\e[38;5;81m'          col-pkg     $'\e[1;3;38;5;27m'   col-url     $'\e[38;5;75m'
    col-ehi     $'\e[1m\e[38;5;210m'    col-meta    $'\e[38;5;57m'          col-pname   $'\e[1;4m\e[32m'     col-var     $'\e[38;5;81m'
    col-error   $'\e[1m\e[38;5;204m'    col-meta2   $'\e[38;5;147m'         col-pre     $'\e[38;5;135m'      col-version $'\e[3;38;5;87m'
    col-failure $'\e[38;5;204m'         col-msg     $'\e[0m'                col-profile $'\e[38;5;148m'      col-warn    $'\e[38;5;214m'

    col-dbg $'\e[2m\e[38;47;107m'"[debug]"$'\e[0m'
    col-e $'\e[1m\e[38;5;204m'"Error"$'\e[0m'":"
    col-i $'\e[1m\e[38;5;82m'"==>"$'\e[0m'
    col-m $'\e[38;5;4m'"==>"$'\e[0m'
    col-w $'\e[1m\e[38;5;214m'"Warning"$'\e[0m'":"

    col--…   "${${${(M)LANG:#*UTF-8*}:+⋯⋯}:-···}"    col-lr "${${${(M)LANG:#*UTF-8*}:+↔}:-"«-»"}"
    col-ndsh "${${${(M)LANG:#*UTF-8*}:+–}:-}"        col-…  "${${${(M)LANG:#*UTF-8*}:+…}:-...}"

    col-mdsh  $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+–}:--}"$'\e[0m'
    col-mmdsh $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+――}:--}"$'\e[0m'

    col-↔     ${${${(M)LANG:#*UTF-8*}:+$'\e[38;5;82m↔\e[0m'}:-$'\e[38;5;82m«-»\e[0m'}
  )
  if [[ ( ${+terminfo} -eq 1 && ${terminfo[colors]} -ge 256 ) || ( ${+termcap} -eq 1 && ${termcap[Co]} -ge 256 ) ]]; then
    ZINIT+=( col-pname $'\e[1;4m\e[38;5;39m' col-uname  $'\e[1;4m\e[38;5;207m' )
  fi
fi

# Hooks
typeset -gAH ZINIT_ZLE_HOOKS_LIST
ZINIT_ZLE_HOOKS_LIST=(
    zle-isearch-exit 1
    zle-isearch-update 1
    zle-line-pre-redraw 1
    zle-line-init 1
    zle-line-finish 1
    zle-history-line-set 1
    zle-keymap-select 1
    paste-insert 1
)
builtin setopt noaliases
# ]]]

#
# Temporary substituting of functions-related functions.
#

# FUNCTION: :zinit-reload-and-run [[[
# Marks given function ($3) for autoloading, and executes it triggering the
# load. $1 is the fpath dedicated to the function, $2 are autoload options.
# This function replaces "autoload -X", because using that on older Zsh
# versions causes problems with traps.
#
# So basically one creates function stub that calls :zinit-reload-and-run()
# instead of "autoload -X".
#
# Author: Bart Schaefer
#
# $1 - FPATH dedicated to function
# $2 - autoload options
# $3 - function name (one that needs autoloading)
:zinit-reload-and-run() {
    local fpath_prefix="$1" autoload_opts="$2" func="$3"
    shift 3

    # Unfunction caller function (its name is given).
    unfunction -- "$func"

    local -a ___fpath
    ___fpath=( ${fpath[@]} )
    local -a +h fpath
    # See #127.
    [[ $FPATH != *${${(@0)fpath_prefix}[1]}* ]] && \
        fpath=( ${(@0)fpath_prefix} ${___fpath[@]} )

    # After this the function exists again.
    builtin autoload ${(s: :)autoload_opts} -- "$func"

    # User wanted to call the function, not only load it.
    "$func" "$@"
} # ]]]
# FUNCTION: :zinit-tmp-subst-autoload [[[
# Hijack plugin's calls to the 'autoload' builtin.
#
# The hijacking gathers report data and runs custom `autoload' function, that doesn't need FPATH.
:zinit-tmp-subst-autoload() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt extendedglob warncreateglobal typesetsilent rcquotes
    local -a opts opts2 custom reply
    local func

    zparseopts -D -E -M -a opts ${(s::):-RTUXdkmrtWzwC} I+=opts2 S+:=custom

    builtin set -- ${@:#--}

    # Process the id-as''/teleid'' to get the plugin dir.
    .zinit-any-to-user-plugin $ZINIT[CUR_USPL2]
    [[ $reply[1] = % ]] && \
        local PLUGIN_DIR="$reply[2]" || \
        local PLUGIN_DIR="$ZINIT[PLUGINS_DIR]/${reply[1]:+$reply[1]---}${reply[2]//\//---}"


    # "fpath elements" ----  those elements that lie inside the plug directory.
    local -a fpath_elements
    fpath_elements=( ${fpath[(r)$PLUGIN_DIR/*]} )

    # Add a function subdirectory to items, if any (this action is
    # according to the Plug Standard version 1.07 and later).
    [[ -d $PLUGIN_DIR/functions ]] && fpath_elements+=( "$PLUGIN_DIR"/functions )

    if (( ${+opts[(r)-X]} )); then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: Failed autoload ${(j: :)opts[@]} $*"
        +zi-log -u2 "{error}builtin autoload required for {obj}${(j: :)opts[@]}{error} option(s)"
        return 1
    fi
    if (( ${+opts[(r)-w]} )); then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "-w-Autoload ${(j: :)opts[@]} ${(j: :)@}"
        fpath+=( $PLUGIN_DIR )
        builtin autoload ${opts[@]} "$@"
        return $?
    fi
    if [[ -n ${(M)@:#+X} ]]; then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Autoload +X ${opts:+${(j: :)opts[@]} }${(j: :)${@:#+X}}"
        local +h FPATH=$PLUGINS_DIR${fpath_elements:+:${(j.:.)fpath_elements[@]}}:$FPATH
        local +h -a fpath
        fpath=( $PLUGIN_DIR $fpath_elements $fpath )
        builtin autoload +X ${opts[@]} "${@:#+X}"
        return $?
    fi

    for func; do
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Autoload $func${opts:+ with options ${(j: :)opts[@]}}"
    done

    integer count retval
    for func; do
        # Real autoload doesn't touch function if it already exists.
        # Author of the idea of FPATH-clean autoloading: Bart Schaefer.
        if (( ${+functions[$func]} != 1 )) {
            builtin setopt noaliases
            if [[ $func == /* ]] && is-at-least 5.4; then
                builtin autoload ${opts[@]} $func
                return $?
            elif [[ $func == /* ]]; then
                if [[ $ZINIT[MUTE_WARNINGS] != (1|true|on|yes) && \
                        -z $ZINIT[WARN_SHOWN_FOR_$ZINIT[CUR_USPL2]] ]]; then
                    +zi-log "{u-warn}Warning{b-warn}: {rst}the plugin {pid}$ZINIT[CUR_USPL2]" \
                        "{rst}is using autoload functions specified by their absolute path," \
                        "which is not supported by this Zsh version ({↔} {version}$ZSH_VERSION{rst}," \
                        "required is Zsh >= {version}5.4{rst})." \
                        "{nl}A fallback mechanism has been applied, which works well only" \
                        "for functions in the plugin {u}{slight}main{rst} directory." \
                        "{nl}(To mute this message, set" \
                        "{var}\$ZINIT[MUTE_WARNINGS]{rst} to a truth value.)"
                    ZINIT[WARN_SHOWN_FOR_$ZINIT[CUR_USPL2]]=1
                fi

                # Workaround
                func=$func:t
            fi
            if [[ ${ZINIT[NEW_AUTOLOAD]} = 2 ]]; then
                builtin autoload ${opts[@]} "$PLUGIN_DIR/$func"
                retval=$?
            elif [[ ${ZINIT[NEW_AUTOLOAD]} = 1 ]]; then
                if (( ${+opts[(r)-C]} )) {
                    local pth nl=$'\n' sel=""
                    for pth ( $PLUGIN_DIR $fpath_elements $fpath ) {
                        [[ -f $pth/$func ]] && { sel=$pth; break; }
                    }
                    if [[ -z $sel ]] {
                        +zi-log '{u-warn}zinit{b-warn}:{error} Couldn''t find autoload function{ehi}:' \
                            "{apo}\`{file}${func}{apo}\`{error} anywhere in {var}\$fpath{error}."
                            retval=1
                    } else {
                        eval "function ${(q)${custom[++count*2]}:-$func} {
                            local body=\"\$(<${(qqq)sel}/${(qqq)func})\" body2
                            () { setopt localoptions extendedglob
                                 body2=\"\${body##[[:space:]]#${func}[[:blank:]]#\(\)[[:space:]]#\{}\"
                                 [[ \$body2 != \$body ]] && \
                                    body2=\"\${body2%\}[[:space:]]#([$nl]#([[:blank:]]#\#[^$nl]#((#e)|[$nl]))#)#}\"
                            }

                            functions[${${(q)custom[count*2]}:-$func}]=\"\$body2\"
                            ${(q)${custom[count*2]}:-$func} \"\$@\"
                        }"
                        retval=$?
                    }
                } else {
                    functions[$func]="
                        local -a fpath
                        fpath=( ${(qqq)PLUGIN_DIR} ${(qqq@)fpath_elements} ${(qqq@)fpath} )
                        builtin autoload -X ${(j: :)${(q-)opts[@]}}
                    "
                    retval=$?
                }
            else
                eval "function ${(q)func} {
                    :zinit-reload-and-run ${(qqq)PLUGIN_DIR}"$'\0'"${(pj,\0,)${(qqq)fpath_elements[@]}} ${(qq)opts[*]} ${(q)func} "'"$@"
                }'
                retval=$?
            fi
            (( ZINIT[ALIASES_OPT] )) && builtin setopt aliases
        }
        if (( ${+opts2[(r)-I]} )) {
            ${custom[count*2]:-$func}
            retval=$?
        }
    done

    return $retval
} # ]]]
# FUNCTION: :zinit-tmp-subst-bindkey [[[
# Function defined to hijack plugin's calls to the `bindkey' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-bindkey() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt extendedglob warncreateglobal typesetsilent noshortloops

    is-at-least 5.3 && \
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Bindkey ${(j: :)${(q+)@}}" || \
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Bindkey ${(j: :)${(q)@}}"

    # Remember to perform the actual bindkey call.
    typeset -a pos
    pos=( "$@" )

    # Check if we have regular bindkey call, i.e.
    # with no options or with -s, plus possible -M
    # option.
    local -A opts
    zparseopts -A opts -D ${(s::):-lLdDAmrsevaR} M: N:

    if (( ${#opts} == 0 ||
        ( ${#opts} == 1 && ${+opts[-M]} ) ||
        ( ${#opts} == 1 && ${+opts[-R]} ) ||
        ( ${#opts} == 1 && ${+opts[-s]} ) ||
        ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-s]} ) ||
        ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-R]} )
    )); then
        local string="${(q)1}" widget="${(q)2}"
        local quoted

        if [[ -n ${ICE[bindmap]} && ${ZINIT_CUR_BIND_MAP[empty]} -eq 1 ]]; then
            local -a pairs
            pairs=( "${(@s,;,)ICE[bindmap]}" )
            if [[ -n ${(M)pairs:#*\\(#e)} ]] {
                local prev
                pairs=( ${pairs[@]//(#b)((*)\\(#e)|(*))/${match[3]:+${prev:+$prev\;}}${match[3]}${${prev::=${match[2]:+${prev:+$prev\;}}${match[2]}}:+}} )
            }
            pairs=( "${(@)${(@)${(@s:->:)pairs}##[[:space:]]##}%%[[:space:]]##}" )
            ZINIT_CUR_BIND_MAP=( empty 0 )
            (( ${#pairs} > 1 && ${#pairs[@]} % 2 == 0 )) && ZINIT_CUR_BIND_MAP+=( "${pairs[@]}" )
        fi

        local bmap_val="${ZINIT_CUR_BIND_MAP[${1}]}"
        if (( !ZINIT_CUR_BIND_MAP[empty] )) {
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[${(qqq)1}]}"
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[${(qqq)${(Q)1}}]}"
            [[ -z $bmap_val ]] && { bmap_val="${ZINIT_CUR_BIND_MAP[!${(qqq)1}]}"; integer val=1; }
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[!${(qqq)${(Q)1}}]}"
        }
        if [[ -n $bmap_val ]]; then
            string="${(q)bmap_val}"
            if (( val )) {
                [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
            } else {
                [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
            }
            .zinit-add-report "${ZINIT[CUR_USPL2]}" ":::Bindkey: combination <$1> changed to <$bmap_val>${${(M)bmap_val:#hold}:+, i.e. ${ZINIT[col-error]}unmapped${ZINIT[col-rst]}}"
            ((1))
        elif [[ ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[UPAR]}} && -n ${${ZINIT[UPAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[DOWNAR]}} && -n ${${ZINIT[DOWNAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[RIGHTAR]}} && -n ${${ZINIT[RIGHTAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[LEFTAR]}} && -n ${${ZINIT[LEFTAR]}[(r);:${(q)1};:]} )
        ]]; then
            string="${(q)bmap_val}"
            if (( val )) {
                [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
            } else {
                [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
            }
            .zinit-add-report "${ZINIT[CUR_USPL2]}" ":::Bindkey: combination <$1> recognized as cursor-key and changed to <${bmap_val}>${${(M)bmap_val:#hold}:+, i.e. ${ZINIT[col-error]}unmapped${ZINIT[col-rst]}}"
        fi
        [[ $bmap_val = hold ]] && return 0

        local prev="${(q)${(s: :)$(builtin bindkey ${(Q)string})}[-1]#undefined-key}"

        # "-M map" given?
        if (( ${+opts[-M]} )); then
            local Mopt=-M
            local Marg="${opts[-M]}"

            Mopt="${(q)Mopt}"
            Marg="${(q)Marg}"

            quoted="$string $widget $prev $Mopt $Marg"
        else
            quoted="$string $widget $prev"
        fi

        # -R given?
        if (( ${+opts[-R]} )); then
            local Ropt=-R
            Ropt="${(q)Ropt}"

            if (( ${+opts[-M]} )); then
                quoted="$quoted $Ropt"
            else
                # Two empty fields for non-existent -M arg.
                local space=_
                space="${(q)space}"
                quoted="$quoted $space $space $Ropt"
            fi
        fi

        quoted="${(q)quoted}"

        # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "
    else
        # bindkey -A newkeymap main?
        # Negative indices for KSH_ARRAYS immunity.
        if [[ ${#opts} -eq 1 && ${+opts[-A]} = 1 && ${#pos} = 3 && ${pos[-1]} = main && ${pos[-2]} != -A ]]; then
            # Save a copy of main keymap.
            (( ZINIT[BINDKEY_MAIN_IDX] = ${ZINIT[BINDKEY_MAIN_IDX]:-0} + 1 ))
            local pname="${ZINIT[CUR_PLUGIN]:-_dtrace}"
            local name="${(q)pname}-main-${ZINIT[BINDKEY_MAIN_IDX]}"
            builtin bindkey -N "$name" main

            # Remember occurence of main keymap substitution, to revert on unload.
            local keys=_ widget=_ prev= optA=-A mapname="${name}" optR=_
            local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optA} ${(q)mapname} ${(q)optR}"
            quoted="${(q)quoted}"

            # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
            [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
            [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "

            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: keymap \`main' copied to \`${name}' because of \`${pos[-2]}' substitution"
        # bindkey -N newkeymap [other].
        elif [[ ${#opts} -eq 1 && ${+opts[-N]} = 1 ]]; then
            local Nopt=-N
            local Narg="${opts[-N]}"

            local keys=_ widget=_ prev= optN=-N mapname="${Narg}" optR=_
            local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optN} ${(q)mapname} ${(q)optR}"
            quoted="${(q)quoted}"

            # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
            [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
            [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "
        else
            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: last bindkey used non-typical options: ${(kv)opts[*]}"
        fi
    fi

    # Actual bindkey.
    builtin bindkey "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-zstyle [[[
# Function defined to hijack plugin's calls to the `zstyle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-zstyle() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob nowarncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Zstyle $*"

    # Remember in order to perform the actual zstyle call.
    typeset -a pos
    pos=( "$@" )

    # Check if we have regular zstyle call, i.e.
    # with no options or with -e.
    local -a opts
    zparseopts -a opts -D ${(s::):-eLdgabsTtm}

    if [[ ${#opts} -eq 0 || ( ${#opts} -eq 1 && ${+opts[(r)-e]} = 1 ) ]]; then
        # Have to quote $1, then $2, then concatenate them, then quote them again.
        local pattern="${(q)1}" style="${(q)2}"
        local ps="$pattern $style"
        ps="${(q)ps}"

        # Remember the zstyle, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[ZSTYLES__${ZINIT[CUR_USPL2]}]+="$ps "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[ZSTYLES___dtrace/_dtrace]+=$ps
    else
        if [[ ! ${#opts[@]} = 1 && ( ${+opts[(r)-s]} = 1 || ${+opts[(r)-b]} = 1 || ${+opts[(r)-a]} = 1 ||
              ${+opts[(r)-t]} = 1 || ${+opts[(r)-T]} = 1 || ${+opts[(r)-m]} = 1 )
        ]]; then
            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: last zstyle used non-typical options: ${opts[*]}"
        fi
    fi

    # Actual zstyle.
    builtin zstyle "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-alias [[[
# Function defined to hijack plugin's calls to the `alias' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-alias() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Alias $*"

    # Remember to perform the actual alias call.
    typeset -a pos
    pos=( "$@" )

    local -a opts
    zparseopts -a opts -D ${(s::):-gs}

    local a quoted tmp
    for a in "$@"; do
        local aname="${a%%[=]*}"
        local avalue="${a#*=}"

        # Check if alias is to be redefined.
        (( ${+aliases[$aname]} )) && .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: redefining alias \`${aname}', previous value: ${aliases[$aname]}"

        local bname=${(q)aliases[$aname]}
        aname="${(q)aname}"

        if (( ${+opts[(r)-s]} )); then
            tmp=-s
            tmp="${(q)tmp}"
            quoted="$aname $bname $tmp"
        elif (( ${+opts[(r)-g]} )); then
            tmp=-g
            tmp="${(q)tmp}"
            quoted="$aname $bname $tmp"
        else
            quoted="$aname $bname"
        fi

        quoted="${(q)quoted}"

        # Remember the alias, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[ALIASES__${ZINIT[CUR_USPL2]}]+="$quoted "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[ALIASES___dtrace/_dtrace]+="$quoted "
    done

    # Actual alias.
    builtin alias "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-zle [[[.
# Function defined to hijack plugin's calls to the `zle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-zle() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Zle $*"

    # Remember to perform the actual zle call.
    typeset -a pos
    pos=( "$@" )

    builtin set -- "${@:#--}"

    # Try to catch game-changing "-N".
    if [[ ( $1 = -N && ( $# = 2 || $# = 3 ) ) || ( $1 = -C && $# = 4 ) ]]; then
            # Hooks.
            if [[ ${ZINIT_ZLE_HOOKS_LIST[$2]} = 1 ]]; then
                local quoted="$2"
                quoted="${(q)quoted}"
                # Remember only when load is in progress (it can be dstart that leads execution here).
                [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_DELETE__${ZINIT[CUR_USPL2]}]+="$quoted "
                # Remember for dtrace.
                [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
            # These will be saved and restored.
            elif (( ${+widgets[$2]} )); then
                # Have to remember original widget "$2" and
                # the copy that it's going to be done.
                local widname="$2" targetfun="${${${(M)1:#-C}:+$4}:-$3}"
                local completion_widget="${${(M)1:#-C}:+$3}"
                local saved_widcontents="${widgets[$widname]}"

                widname="${(q)widname}"
                completion_widget="${(q)completion_widget}"
                targetfun="${(q)targetfun}"
                saved_widcontents="${(q)saved_widcontents}"
                local quoted="$1 $widname $completion_widget $targetfun $saved_widcontents"
                quoted="${(q)quoted}"
                # Remember only when load is in progress (it can be dstart that leads execution here).
                [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_SAVED__${ZINIT[CUR_USPL2]}]+="$quoted "
                # Remember for dtrace.
                [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_SAVED___dtrace/_dtrace]+="$quoted "
             # These will be deleted.
             else
                 .zinit-add-report "${ZINIT[CUR_USPL2]}" "Note: a new widget created via zle -N: \`$2'"
                 local quoted="$2"
                 quoted="${(q)quoted}"
                 # Remember only when load is in progress (it can be dstart that leads execution here).
                 [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_DELETE__${ZINIT[CUR_USPL2]}]+="$quoted "
                 # Remember for dtrace.
                 [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
             fi
    fi

    # Actual zle.
    builtin zle "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-compdef [[[
# Function defined to hijack plugin's calls to the `compdef' function.
# The hijacking is not only for reporting, but also to save compdef
# calls so that `compinit' can be called after loading plugins.
:zinit-tmp-subst-compdef() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Saving \`compdef $*' for replay"
    ZINIT_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" )

    return 0 # testable
} # ]]]
# FUNCTION: .zinit-tmp-subst-on [[[
# Turn on temporary substituting of functions of builtins and functions according to passed
# mode ("load", "light", "light-b" or "compdef"). The temporary substituting of functions is
# to gather report data, and to hijack 'autoload', 'bindkey' and 'compdef' calls.
.zinit-tmp-subst-on() {
    local mode="$1"

    # Enable temporary substituting of functions only once.
    #
    # One could expect possibility of widening of temporary substituting of functions, however
    # such sequence doesn't exist, e.g. "light" then "load"/"dtrace", "compdef" then "load"/
    # "dtrace", "light" then "compdef", "compdef" then "light".
    #
    # It is always "dtrace" then "load" (i.e. dtrace then load) "dtrace" then "light" (i.e.:
    # dtrace then light load) "dtrace" then "compdef" (i.e.: dtrace then snippet).
    [[ ${ZINIT[TMP_SUBST]} != inactive ]] && builtin return 0

    ZINIT[TMP_SUBST]="$mode"

    # The point about backuping is: does the key exist in functions array.
    # If it does exist, then it will also exist as ZINIT[bkp-*].

    # Defensive code, shouldn't be needed.
    builtin unset "ZINIT[bkp-autoload]" "ZINIT[bkp-compdef]"  # 0, E.

    if [[ $mode != compdef ]]; then
        # 0. Used, but not in temporary restoration, which doesn't happen for autoload.
        (( ${+functions[autoload]} )) && ZINIT[bkp-autoload]="${functions[autoload]}"
        functions[autoload]=':zinit-tmp-subst-autoload "$@";'
    fi

    # E. Always shade compdef.
    (( ${+functions[compdef]} )) && ZINIT[bkp-compdef]="${functions[compdef]}"
    functions[compdef]=':zinit-tmp-subst-compdef "$@";'

    # Temporarily replace `source' if subst'' given.
    if [[ -n ${ICE[subst]} ]] {
        (( ${+functions[source]} )) && ZINIT[bkp-source]="${functions[source]}"
        (( ${+functions[.]} )) && ZINIT[bkp-.]="${functions[.]}"
        (( ${+functions[.zinit-service]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-additional.zsh"
        functions[source]=':zinit-tmp-subst-source "$@";'
        functions[.]=':zinit-tmp-subst-source "$@";'
    }

    # Light and compdef temporary substituting of functions stops here. Dtrace and load go on.
    [[ ( $mode = light && ${+ICE[trackbinds]} -eq 0 ) || $mode = compdef ]] && return 0
... truncated; 2,551 more lines
.claude/worktrees/agent-abf1fcdc5c1253122/tests/recorder_corpus/zinit/zinit.zsh — 3,351 LOC
#
# zdharma-continuum/zinit/zinit.zsh
# Copyright (c) 2016-2021 Sebastian Gniazdowski
# Copyright (c) 2021-2023 zdharma-continuum
# Homepage: https://github.com/zdharma-continuum/zinit
# License: MIT License
#

#
# Main state variables.
#

typeset -gaH ZINIT_REGISTERED_PLUGINS ZINIT_TASKS ZINIT_RUN
typeset -ga zsh_loaded_plugins
if (( !${#ZINIT_TASKS} )) { ZINIT_TASKS=( "<no-data>" ); }
# Snippets loaded, url -> file name.
typeset -gAH ZINIT ZINIT_SNIPPETS ZINIT_REPORTS ZINIT_ICES ZINIT_SICE ZINIT_CUR_BIND_MAP ZINIT_EXTS ZINIT_EXTS2
typeset -gaH ZINIT_COMPDEF_REPLAY

# Compatibility with pre-rename project (Zplugin).
typeset -gAH ZPLGM
ZINIT=( "${(kv)ZPLGM[@]}" "${(kv)ZINIT[@]}" )
unset ZPLGM

#
# Common needed values.
#

[[ ! -e ${ZINIT[BIN_DIR]}/zinit.zsh ]] && ZINIT[BIN_DIR]=

# Respect the plugin standard too.
ZINIT[ZERO]="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
[[ ! -o functionargzero || ${options[posixargzero]} = on || ${ZINIT[ZERO]} != */* ]] && ZINIT[ZERO]="${(%):-%N}"

: ${ZINIT[BIN_DIR]:="${ZINIT[ZERO]:h}"}
[[ ${ZINIT[BIN_DIR]} = \~* ]] && ZINIT[BIN_DIR]=${~ZINIT[BIN_DIR]}

# Make ZINIT[BIN_DIR] path absolute.
ZINIT[BIN_DIR]="${${(M)ZINIT[BIN_DIR]:#/*}:-$PWD/${ZINIT[BIN_DIR]}}"

# Final test of ZINIT[BIN_DIR].
if [[ ! -e ${ZINIT[BIN_DIR]}/zinit.zsh ]]; then
    builtin print -P "%F{196}Could not establish ZINIT[BIN_DIR] hash field. It should point where Zinit's Git repository is.%f"
    return 1
fi

# User can override ZINIT[HOME_DIR].
if [[ -z ${ZINIT[HOME_DIR]} ]]; then
    # Search for zinit home in the usual locations
    if [[ -d ${XDG_DATA_HOME:-${HOME}/.local/share}/zinit ]]; then
        ZINIT[HOME_DIR]="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
    elif [[ -d $HOME/.zinit ]]; then
        ZINIT[HOME_DIR]="$HOME/.zinit"
    elif [[ -d ${ZDOTDIR:-$HOME}/.zinit ]]; then
        ZINIT[HOME_DIR]="${ZDOTDIR:-$HOME}/.zinit"
    elif [[ -d $HOME/.zplugin ]]; then
        ZINIT[HOME_DIR]="$HOME/.zplugin"
    elif [[ -d ${ZDOTDIR:-$HOME}/.zplugin ]]; then
        ZINIT[HOME_DIR]="${ZDOTDIR:-$HOME}/.zplugin"
    else
        ZINIT[HOME_DIR]="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
    fi
fi

if [[ -z ${ZINIT[LIST_COMMAND]} ]]; then
    if (( ${+commands[eza]} )); then
        ZINIT[LIST_COMMAND]='eza --color=always --tree --icons -L3'
    elif (( ${+commands[exa]} )); then
        ZINIT[LIST_COMMAND]='exa --color=always --tree --icons -L3'
    elif (( ${+commands[tree]} )); then
        ZINIT[LIST_COMMAND]='tree -L 3 -C --charset utf-8'
    else
        ZINIT[LIST_COMMAND]='ls --tree'
    fi
fi

ZINIT[ice-list]="\
\!bash|\!csh|\!ksh|\!sh|\
aliases|as|atclone|atdelete|atinit|atload|atpull|autoload|\
bash|binary|bindmap|blockf|bpick|build|\
cloneonly|cloneopts|cmake|compile|completions|configure|countdown|cp|csh|\
debug|depth|\
extract|\
from|git|\
has|\
id-as|if|install|is-snippet|\
ksh|\
light-mode|link|load|lucid|\
make|multisrc|mv|nocd|nocompile|nocompletions|notify|null|\
on-update-of|opts|\
pack|param|pick|proto|ps-on-unload|ps-on-update|pullopts|\
reset|reset-prompt|run-atpull|\
service|sh|silent|src|subscribe|subst|svn|\
teleid|trackbinds|trigger-load|\
unload|\
ver|verbose|\
wait|wrap"
ZINIT[nval-ice-list]="\
\!bash|\!csh|\!ksh|\!sh|\
aliases|\
bash|binary|blockf|\
cloneonly|cloneopts|cmake|configure|countdown|csh|\
debug|\
git|\
is-snippet|\
ksh|\
light-mode|lucid|\
make|\
nocd|nocompile|nocompletions|notify|null|\
pullopts|\
reset|run-atpull|\
sh|silent|\
trackbinds|\
verbose"
ZINIT[cmds]="\
add-fpath|\
bindkeys|\
cclear|cd|cdclear|cdisable|cdlist|cdreplay|cenable|changes|compile|compiled|compinit|completions|create|creinstall|csearch|cuninstall|\
delete|debug|\
edit|env-whitelist|\
fpath|\
glance|\
help|--help|-h|\
ice|\
light|load|\
man|module|\
plugins|\
recall|recently|report|run|\
self-update|snippet|snippets|srv|status|stress|\
times|\
uncompile|unload|update|\
version|\
zstatus"

# Can be customized.
: ${ZINIT[COMPLETIONS_DIR]:=${ZINIT[HOME_DIR]}/completions}
: ${ZINIT[MODULE_DIR]:=${ZINIT[HOME_DIR]}/module}
: ${ZINIT[PACKAGES_BRANCH]:=HEAD}
: ${ZINIT[PACKAGES_REPO]:=zdharma-continuum/zinit-packages}
: ${ZINIT[PLUGINS_DIR]:=${ZINIT[HOME_DIR]}/plugins}
: ${ZINIT[POLARIS_DIR]:=${ZINIT[HOME_DIR]}/polaris}
: ${ZINIT[SERVICES_DIR]:=${ZINIT[HOME_DIR]}/services}
: ${ZINIT[SNIPPETS_DIR]:=${ZINIT[HOME_DIR]}/snippets}
: ${ZINIT[ZPFX]:=${ZINIT[HOME_DIR]}/polaris}
typeset -g ZPFX
: ${ZPFX:=${ZINIT[ZPFX]}}
: ${ZINIT[ALIASES_OPT]::=${${options[aliases]:#off}:+1}}
: ${ZINIT[MAN_DIR]:=${ZPFX}/man}

ZINIT[PLUGINS_DIR]=${~ZINIT[PLUGINS_DIR]}   ZINIT[COMPLETIONS_DIR]=${~ZINIT[COMPLETIONS_DIR]}
ZINIT[SNIPPETS_DIR]=${~ZINIT[SNIPPETS_DIR]} ZINIT[SERVICES_DIR]=${~ZINIT[SERVICES_DIR]}

# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
  ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/zinit"
fi

export ZPFX=${~ZPFX} ZSH_CACHE_DIR="${ZSH_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/zinit}" \
    PMSPEC=0uUpiPsf
[[ -z ${path[(re)$ZPFX/bin]} ]] && [[ -d "$ZPFX/bin" ]] && path=( "$ZPFX/bin" "${path[@]}" )
[[ -z ${path[(re)$ZPFX/sbin]} ]] && [[ -d "$ZPFX/sbin" ]] && path=( "$ZPFX/sbin" "${path[@]}" )

hash -f
hash -d zinit=${ZINIT[HOME_DIR]}
hash -d plugins=${ZINIT[PLUGINS_DIR]}
hash -d zpfx=${ZINIT[HOME_DIR]}/polaris

# Add completions directory to fpath.
[[ -z ${fpath[(re)${ZINIT[COMPLETIONS_DIR]}]} ]] && fpath=( "${ZINIT[COMPLETIONS_DIR]}" "${fpath[@]}" )

[[ ! -d $ZSH_CACHE_DIR ]] && command mkdir -p "$ZSH_CACHE_DIR"
[[ -n ${ZINIT[ZCOMPDUMP_PATH]} ]] && ZINIT[ZCOMPDUMP_PATH]=${~ZINIT[ZCOMPDUMP_PATH]}

# Create "$ZSH_CACHE_DIR/completions" directory
[[ ! -d "$ZSH_CACHE_DIR/completions" ]] && command mkdir -p "$ZSH_CACHE_DIR/completions"
# Add "$ZSH_CACHE_DIR/completions" diretory to fpath
[[ -z ${fpath[(re)$ZSH_CACHE_DIR/completions]} ]] && fpath=( "$ZSH_CACHE_DIR/completions" "${fpath[@]}" )

ZINIT[UPAR]=";:^[[A;:^[OA;:\\e[A;:\\eOA;:${termcap[ku]/$'\e'/^\[};:${terminfo[kcuu1]/$'\e'/^\[};:"
ZINIT[DOWNAR]=";:^[[B;:^[OB;:\\e[B;:\\eOB;:${termcap[kd]/$'\e'/^\[};:${terminfo[kcud1]/$'\e'/^\[};:"
ZINIT[RIGHTAR]=";:^[[C;:^[OC;:\\e[C;:\\eOC;:${termcap[kr]/$'\e'/^\[};:${terminfo[kcuf1]/$'\e'/^\[};:"
ZINIT[LEFTAR]=";:^[[D;:^[OD;:\\e[D;:\\eOD;:${termcap[kl]/$'\e'/^\[};:${terminfo[kcub1]/$'\e'/^\[};:"

builtin autoload -Uz is-at-least
is-at-least 5.1 && ZINIT[NEW_AUTOLOAD]=1 || ZINIT[NEW_AUTOLOAD]=0
#is-at-least 5.4 && ZINIT[NEW_AUTOLOAD]=2

# Parameters [[[
# temporary substituting of functions
ZINIT[TMP_SUBST]=inactive ZINIT[DTRACE]=0 ZINIT[CUR_PLUGIN]=

# ice
declare -gA ZINIT_1MAP ZINIT_2MAP
ZINIT_1MAP=(
    OMZ:: https://github.com/ohmyzsh/ohmyzsh/trunk/
    OMZP:: https://github.com/ohmyzsh/ohmyzsh/trunk/plugins/
    OMZT:: https://github.com/ohmyzsh/ohmyzsh/trunk/themes/
    OMZL:: https://github.com/ohmyzsh/ohmyzsh/trunk/lib/
    PZT:: https://github.com/sorin-ionescu/prezto/trunk/
    PZTM:: https://github.com/sorin-ionescu/prezto/trunk/modules/
)
ZINIT_2MAP=(
    OMZ:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/
    OMZP:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/
    OMZT:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/themes/
    OMZL:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/lib/
    PZT:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/
    PZTM:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/modules/
)
# ]]]

# Init [[[
zmodload zsh/zutil || { builtin print -P "%F{196}zsh/zutil module is required, aborting Zinit set up.%f"; return 1; }
zmodload zsh/parameter || { builtin print -P "%F{196}zsh/parameter module is required, aborting Zinit set up.%f"; return 1; }
zmodload zsh/term{cap,info} 2>/dev/null
autoload -Uz colors && colors

if [[ -z $SOURCED && ( ${+terminfo} -eq 1 && -n ${terminfo[colors]} ) || ( ${+termcap} -eq 1 && -n ${termcap[Co]} ) ]]; then
  ZINIT+=(
    col-annex   $'\e[38;5;153m'         col-faint   $'\e[38;5;238m'         col-msg2    $'\e[38;5;172m'      col-quo     $'\e[1;38;5;33m'
    col-apo     $'\e[1;38;5;45m'        col-file    $'\e[3;38;5;117m'       col-msg3    $'\e[38;5;238m'      col-quos    $'\e[1;38;5;160m'
    col-aps     $'\e[38;5;117m'         col-flag    $'\e[1;3;38;5;79m'      col-nb      $'\e[22m'            col-rst     $'\e[0m'
    col-b       $'\e[1m'                col-func    $'\e[38;5;219m'         col-nit     $'\e[23m'            col-slight  $'\e[38;5;230m'
    col-b-lhi   $'\e[1m\e[38;5;75m'     col-glob    $'\e[38;5;227m'         col-nl      $'\n'                col-st      $'\e[9m'
    col-b-warn  $'\e[1;38;5;214m'       col-happy   $'\e[1m\e[38;5;82m'     col-note    $'\e[38;5;148m'      col-tab     $' \t '
    col-bapo    $'\e[1;38;5;220m'       col-hi      $'\e[1m\e[38;5;183m'    col-nst     $'\e[29m'            col-term    $'\e[38;5;185m'
    col-baps    $'\e[1;38;5;82m'        col-ice     $'\e[38;5;39m'          col-nu      $'\e[24m'            col-th-bar  $'\e[38;5;82m'
    col-bar     $'\e[38;5;82m'          col-id-as   $'\e[4;38;5;220m'       col-num     $'\e[3;38;5;155m'    col-time    $'\e[38;5;220m'
    col-bcmd    $'\e[38;5;220m'         col-info    $'\e[38;5;82m'          col-obj     $'\e[38;5;218m'      col-txt     $'\e[38;5;254m'
    col-bspc    $'\b'                   col-info2   $'\e[38;5;227m'         col-obj2    $'\e[38;5;118m'      col-u       $'\e[4m'
    col-cmd     $'\e[38;5;82m'          col-info3   $'\e[1m\e[38;5;227m'    col-ok      $'\e[38;5;220m'      col-u-warn  $'\e[4;38;5;214m'
    col-data    $'\e[38;5;82m'          col-it      $'\e[3m'                col-opt     $'\e[38;5;219m'      col-uname   $'\e[1;4m\e[35m'
    col-data2   $'\e[38;5;117m'         col-keyword $'\e[32m'               col-p       $'\e[38;5;81m'       col-uninst  $'\e[38;5;118m'
    col-dir     $'\e[3;38;5;153m'       col-lhi     $'\e[38;5;81m'          col-pkg     $'\e[1;3;38;5;27m'   col-url     $'\e[38;5;75m'
    col-ehi     $'\e[1m\e[38;5;210m'    col-meta    $'\e[38;5;57m'          col-pname   $'\e[1;4m\e[32m'     col-var     $'\e[38;5;81m'
    col-error   $'\e[1m\e[38;5;204m'    col-meta2   $'\e[38;5;147m'         col-pre     $'\e[38;5;135m'      col-version $'\e[3;38;5;87m'
    col-failure $'\e[38;5;204m'         col-msg     $'\e[0m'                col-profile $'\e[38;5;148m'      col-warn    $'\e[38;5;214m'

    col-dbg $'\e[2m\e[38;47;107m'"[debug]"$'\e[0m'
    col-e $'\e[1m\e[38;5;204m'"Error"$'\e[0m'":"
    col-i $'\e[1m\e[38;5;82m'"==>"$'\e[0m'
    col-m $'\e[38;5;4m'"==>"$'\e[0m'
    col-w $'\e[1m\e[38;5;214m'"Warning"$'\e[0m'":"

    col--…   "${${${(M)LANG:#*UTF-8*}:+⋯⋯}:-···}"    col-lr "${${${(M)LANG:#*UTF-8*}:+↔}:-"«-»"}"
    col-ndsh "${${${(M)LANG:#*UTF-8*}:+–}:-}"        col-…  "${${${(M)LANG:#*UTF-8*}:+…}:-...}"

    col-mdsh  $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+–}:--}"$'\e[0m'
    col-mmdsh $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+――}:--}"$'\e[0m'

    col-↔     ${${${(M)LANG:#*UTF-8*}:+$'\e[38;5;82m↔\e[0m'}:-$'\e[38;5;82m«-»\e[0m'}
  )
  if [[ ( ${+terminfo} -eq 1 && ${terminfo[colors]} -ge 256 ) || ( ${+termcap} -eq 1 && ${termcap[Co]} -ge 256 ) ]]; then
    ZINIT+=( col-pname $'\e[1;4m\e[38;5;39m' col-uname  $'\e[1;4m\e[38;5;207m' )
  fi
fi

# Hooks
typeset -gAH ZINIT_ZLE_HOOKS_LIST
ZINIT_ZLE_HOOKS_LIST=(
    zle-isearch-exit 1
    zle-isearch-update 1
    zle-line-pre-redraw 1
    zle-line-init 1
    zle-line-finish 1
    zle-history-line-set 1
    zle-keymap-select 1
    paste-insert 1
)
builtin setopt noaliases
# ]]]

#
# Temporary substituting of functions-related functions.
#

# FUNCTION: :zinit-reload-and-run [[[
# Marks given function ($3) for autoloading, and executes it triggering the
# load. $1 is the fpath dedicated to the function, $2 are autoload options.
# This function replaces "autoload -X", because using that on older Zsh
# versions causes problems with traps.
#
# So basically one creates function stub that calls :zinit-reload-and-run()
# instead of "autoload -X".
#
# Author: Bart Schaefer
#
# $1 - FPATH dedicated to function
# $2 - autoload options
# $3 - function name (one that needs autoloading)
:zinit-reload-and-run() {
    local fpath_prefix="$1" autoload_opts="$2" func="$3"
    shift 3

    # Unfunction caller function (its name is given).
    unfunction -- "$func"

    local -a ___fpath
    ___fpath=( ${fpath[@]} )
    local -a +h fpath
    # See #127.
    [[ $FPATH != *${${(@0)fpath_prefix}[1]}* ]] && \
        fpath=( ${(@0)fpath_prefix} ${___fpath[@]} )

    # After this the function exists again.
    builtin autoload ${(s: :)autoload_opts} -- "$func"

    # User wanted to call the function, not only load it.
    "$func" "$@"
} # ]]]
# FUNCTION: :zinit-tmp-subst-autoload [[[
# Hijack plugin's calls to the 'autoload' builtin.
#
# The hijacking gathers report data and runs custom `autoload' function, that doesn't need FPATH.
:zinit-tmp-subst-autoload() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt extendedglob warncreateglobal typesetsilent rcquotes
    local -a opts opts2 custom reply
    local func

    zparseopts -D -E -M -a opts ${(s::):-RTUXdkmrtWzwC} I+=opts2 S+:=custom

    builtin set -- ${@:#--}

    # Process the id-as''/teleid'' to get the plugin dir.
    .zinit-any-to-user-plugin $ZINIT[CUR_USPL2]
    [[ $reply[1] = % ]] && \
        local PLUGIN_DIR="$reply[2]" || \
        local PLUGIN_DIR="$ZINIT[PLUGINS_DIR]/${reply[1]:+$reply[1]---}${reply[2]//\//---}"


    # "fpath elements" ----  those elements that lie inside the plug directory.
    local -a fpath_elements
    fpath_elements=( ${fpath[(r)$PLUGIN_DIR/*]} )

    # Add a function subdirectory to items, if any (this action is
    # according to the Plug Standard version 1.07 and later).
    [[ -d $PLUGIN_DIR/functions ]] && fpath_elements+=( "$PLUGIN_DIR"/functions )

    if (( ${+opts[(r)-X]} )); then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: Failed autoload ${(j: :)opts[@]} $*"
        +zi-log -u2 "{error}builtin autoload required for {obj}${(j: :)opts[@]}{error} option(s)"
        return 1
    fi
    if (( ${+opts[(r)-w]} )); then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "-w-Autoload ${(j: :)opts[@]} ${(j: :)@}"
        fpath+=( $PLUGIN_DIR )
        builtin autoload ${opts[@]} "$@"
        return $?
    fi
    if [[ -n ${(M)@:#+X} ]]; then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Autoload +X ${opts:+${(j: :)opts[@]} }${(j: :)${@:#+X}}"
        local +h FPATH=$PLUGINS_DIR${fpath_elements:+:${(j.:.)fpath_elements[@]}}:$FPATH
        local +h -a fpath
        fpath=( $PLUGIN_DIR $fpath_elements $fpath )
        builtin autoload +X ${opts[@]} "${@:#+X}"
        return $?
    fi

    for func; do
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Autoload $func${opts:+ with options ${(j: :)opts[@]}}"
    done

    integer count retval
    for func; do
        # Real autoload doesn't touch function if it already exists.
        # Author of the idea of FPATH-clean autoloading: Bart Schaefer.
        if (( ${+functions[$func]} != 1 )) {
            builtin setopt noaliases
            if [[ $func == /* ]] && is-at-least 5.4; then
                builtin autoload ${opts[@]} $func
                return $?
            elif [[ $func == /* ]]; then
                if [[ $ZINIT[MUTE_WARNINGS] != (1|true|on|yes) && \
                        -z $ZINIT[WARN_SHOWN_FOR_$ZINIT[CUR_USPL2]] ]]; then
                    +zi-log "{u-warn}Warning{b-warn}: {rst}the plugin {pid}$ZINIT[CUR_USPL2]" \
                        "{rst}is using autoload functions specified by their absolute path," \
                        "which is not supported by this Zsh version ({↔} {version}$ZSH_VERSION{rst}," \
                        "required is Zsh >= {version}5.4{rst})." \
                        "{nl}A fallback mechanism has been applied, which works well only" \
                        "for functions in the plugin {u}{slight}main{rst} directory." \
                        "{nl}(To mute this message, set" \
                        "{var}\$ZINIT[MUTE_WARNINGS]{rst} to a truth value.)"
                    ZINIT[WARN_SHOWN_FOR_$ZINIT[CUR_USPL2]]=1
                fi

                # Workaround
                func=$func:t
            fi
            if [[ ${ZINIT[NEW_AUTOLOAD]} = 2 ]]; then
                builtin autoload ${opts[@]} "$PLUGIN_DIR/$func"
                retval=$?
            elif [[ ${ZINIT[NEW_AUTOLOAD]} = 1 ]]; then
                if (( ${+opts[(r)-C]} )) {
                    local pth nl=$'\n' sel=""
                    for pth ( $PLUGIN_DIR $fpath_elements $fpath ) {
                        [[ -f $pth/$func ]] && { sel=$pth; break; }
                    }
                    if [[ -z $sel ]] {
                        +zi-log '{u-warn}zinit{b-warn}:{error} Couldn''t find autoload function{ehi}:' \
                            "{apo}\`{file}${func}{apo}\`{error} anywhere in {var}\$fpath{error}."
                            retval=1
                    } else {
                        eval "function ${(q)${custom[++count*2]}:-$func} {
                            local body=\"\$(<${(qqq)sel}/${(qqq)func})\" body2
                            () { setopt localoptions extendedglob
                                 body2=\"\${body##[[:space:]]#${func}[[:blank:]]#\(\)[[:space:]]#\{}\"
                                 [[ \$body2 != \$body ]] && \
                                    body2=\"\${body2%\}[[:space:]]#([$nl]#([[:blank:]]#\#[^$nl]#((#e)|[$nl]))#)#}\"
                            }

                            functions[${${(q)custom[count*2]}:-$func}]=\"\$body2\"
                            ${(q)${custom[count*2]}:-$func} \"\$@\"
                        }"
                        retval=$?
                    }
                } else {
                    functions[$func]="
                        local -a fpath
                        fpath=( ${(qqq)PLUGIN_DIR} ${(qqq@)fpath_elements} ${(qqq@)fpath} )
                        builtin autoload -X ${(j: :)${(q-)opts[@]}}
                    "
                    retval=$?
                }
            else
                eval "function ${(q)func} {
                    :zinit-reload-and-run ${(qqq)PLUGIN_DIR}"$'\0'"${(pj,\0,)${(qqq)fpath_elements[@]}} ${(qq)opts[*]} ${(q)func} "'"$@"
                }'
                retval=$?
            fi
            (( ZINIT[ALIASES_OPT] )) && builtin setopt aliases
        }
        if (( ${+opts2[(r)-I]} )) {
            ${custom[count*2]:-$func}
            retval=$?
        }
    done

    return $retval
} # ]]]
# FUNCTION: :zinit-tmp-subst-bindkey [[[
# Function defined to hijack plugin's calls to the `bindkey' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-bindkey() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt extendedglob warncreateglobal typesetsilent noshortloops

    is-at-least 5.3 && \
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Bindkey ${(j: :)${(q+)@}}" || \
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Bindkey ${(j: :)${(q)@}}"

    # Remember to perform the actual bindkey call.
    typeset -a pos
    pos=( "$@" )

    # Check if we have regular bindkey call, i.e.
    # with no options or with -s, plus possible -M
    # option.
    local -A opts
    zparseopts -A opts -D ${(s::):-lLdDAmrsevaR} M: N:

    if (( ${#opts} == 0 ||
        ( ${#opts} == 1 && ${+opts[-M]} ) ||
        ( ${#opts} == 1 && ${+opts[-R]} ) ||
        ( ${#opts} == 1 && ${+opts[-s]} ) ||
        ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-s]} ) ||
        ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-R]} )
    )); then
        local string="${(q)1}" widget="${(q)2}"
        local quoted

        if [[ -n ${ICE[bindmap]} && ${ZINIT_CUR_BIND_MAP[empty]} -eq 1 ]]; then
            local -a pairs
            pairs=( "${(@s,;,)ICE[bindmap]}" )
            if [[ -n ${(M)pairs:#*\\(#e)} ]] {
                local prev
                pairs=( ${pairs[@]//(#b)((*)\\(#e)|(*))/${match[3]:+${prev:+$prev\;}}${match[3]}${${prev::=${match[2]:+${prev:+$prev\;}}${match[2]}}:+}} )
            }
            pairs=( "${(@)${(@)${(@s:->:)pairs}##[[:space:]]##}%%[[:space:]]##}" )
            ZINIT_CUR_BIND_MAP=( empty 0 )
            (( ${#pairs} > 1 && ${#pairs[@]} % 2 == 0 )) && ZINIT_CUR_BIND_MAP+=( "${pairs[@]}" )
        fi

        local bmap_val="${ZINIT_CUR_BIND_MAP[${1}]}"
        if (( !ZINIT_CUR_BIND_MAP[empty] )) {
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[${(qqq)1}]}"
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[${(qqq)${(Q)1}}]}"
            [[ -z $bmap_val ]] && { bmap_val="${ZINIT_CUR_BIND_MAP[!${(qqq)1}]}"; integer val=1; }
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[!${(qqq)${(Q)1}}]}"
        }
        if [[ -n $bmap_val ]]; then
            string="${(q)bmap_val}"
            if (( val )) {
                [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
            } else {
                [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
            }
            .zinit-add-report "${ZINIT[CUR_USPL2]}" ":::Bindkey: combination <$1> changed to <$bmap_val>${${(M)bmap_val:#hold}:+, i.e. ${ZINIT[col-error]}unmapped${ZINIT[col-rst]}}"
            ((1))
        elif [[ ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[UPAR]}} && -n ${${ZINIT[UPAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[DOWNAR]}} && -n ${${ZINIT[DOWNAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[RIGHTAR]}} && -n ${${ZINIT[RIGHTAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[LEFTAR]}} && -n ${${ZINIT[LEFTAR]}[(r);:${(q)1};:]} )
        ]]; then
            string="${(q)bmap_val}"
            if (( val )) {
                [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
            } else {
                [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
            }
            .zinit-add-report "${ZINIT[CUR_USPL2]}" ":::Bindkey: combination <$1> recognized as cursor-key and changed to <${bmap_val}>${${(M)bmap_val:#hold}:+, i.e. ${ZINIT[col-error]}unmapped${ZINIT[col-rst]}}"
        fi
        [[ $bmap_val = hold ]] && return 0

        local prev="${(q)${(s: :)$(builtin bindkey ${(Q)string})}[-1]#undefined-key}"

        # "-M map" given?
        if (( ${+opts[-M]} )); then
            local Mopt=-M
            local Marg="${opts[-M]}"

            Mopt="${(q)Mopt}"
            Marg="${(q)Marg}"

            quoted="$string $widget $prev $Mopt $Marg"
        else
            quoted="$string $widget $prev"
        fi

        # -R given?
        if (( ${+opts[-R]} )); then
            local Ropt=-R
            Ropt="${(q)Ropt}"

            if (( ${+opts[-M]} )); then
                quoted="$quoted $Ropt"
            else
                # Two empty fields for non-existent -M arg.
                local space=_
                space="${(q)space}"
                quoted="$quoted $space $space $Ropt"
            fi
        fi

        quoted="${(q)quoted}"

        # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "
    else
        # bindkey -A newkeymap main?
        # Negative indices for KSH_ARRAYS immunity.
        if [[ ${#opts} -eq 1 && ${+opts[-A]} = 1 && ${#pos} = 3 && ${pos[-1]} = main && ${pos[-2]} != -A ]]; then
            # Save a copy of main keymap.
            (( ZINIT[BINDKEY_MAIN_IDX] = ${ZINIT[BINDKEY_MAIN_IDX]:-0} + 1 ))
            local pname="${ZINIT[CUR_PLUGIN]:-_dtrace}"
            local name="${(q)pname}-main-${ZINIT[BINDKEY_MAIN_IDX]}"
            builtin bindkey -N "$name" main

            # Remember occurence of main keymap substitution, to revert on unload.
            local keys=_ widget=_ prev= optA=-A mapname="${name}" optR=_
            local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optA} ${(q)mapname} ${(q)optR}"
            quoted="${(q)quoted}"

            # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
            [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
            [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "

            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: keymap \`main' copied to \`${name}' because of \`${pos[-2]}' substitution"
        # bindkey -N newkeymap [other].
        elif [[ ${#opts} -eq 1 && ${+opts[-N]} = 1 ]]; then
            local Nopt=-N
            local Narg="${opts[-N]}"

            local keys=_ widget=_ prev= optN=-N mapname="${Narg}" optR=_
            local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optN} ${(q)mapname} ${(q)optR}"
            quoted="${(q)quoted}"

            # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
            [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
            [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "
        else
            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: last bindkey used non-typical options: ${(kv)opts[*]}"
        fi
    fi

    # Actual bindkey.
    builtin bindkey "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-zstyle [[[
# Function defined to hijack plugin's calls to the `zstyle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-zstyle() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob nowarncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Zstyle $*"

    # Remember in order to perform the actual zstyle call.
    typeset -a pos
    pos=( "$@" )

    # Check if we have regular zstyle call, i.e.
    # with no options or with -e.
    local -a opts
    zparseopts -a opts -D ${(s::):-eLdgabsTtm}

    if [[ ${#opts} -eq 0 || ( ${#opts} -eq 1 && ${+opts[(r)-e]} = 1 ) ]]; then
        # Have to quote $1, then $2, then concatenate them, then quote them again.
        local pattern="${(q)1}" style="${(q)2}"
        local ps="$pattern $style"
        ps="${(q)ps}"

        # Remember the zstyle, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[ZSTYLES__${ZINIT[CUR_USPL2]}]+="$ps "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[ZSTYLES___dtrace/_dtrace]+=$ps
    else
        if [[ ! ${#opts[@]} = 1 && ( ${+opts[(r)-s]} = 1 || ${+opts[(r)-b]} = 1 || ${+opts[(r)-a]} = 1 ||
              ${+opts[(r)-t]} = 1 || ${+opts[(r)-T]} = 1 || ${+opts[(r)-m]} = 1 )
        ]]; then
            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: last zstyle used non-typical options: ${opts[*]}"
        fi
    fi

    # Actual zstyle.
    builtin zstyle "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-alias [[[
# Function defined to hijack plugin's calls to the `alias' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-alias() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Alias $*"

    # Remember to perform the actual alias call.
    typeset -a pos
    pos=( "$@" )

    local -a opts
    zparseopts -a opts -D ${(s::):-gs}

    local a quoted tmp
    for a in "$@"; do
        local aname="${a%%[=]*}"
        local avalue="${a#*=}"

        # Check if alias is to be redefined.
        (( ${+aliases[$aname]} )) && .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: redefining alias \`${aname}', previous value: ${aliases[$aname]}"

        local bname=${(q)aliases[$aname]}
        aname="${(q)aname}"

        if (( ${+opts[(r)-s]} )); then
            tmp=-s
            tmp="${(q)tmp}"
            quoted="$aname $bname $tmp"
        elif (( ${+opts[(r)-g]} )); then
            tmp=-g
            tmp="${(q)tmp}"
            quoted="$aname $bname $tmp"
        else
            quoted="$aname $bname"
        fi

        quoted="${(q)quoted}"

        # Remember the alias, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[ALIASES__${ZINIT[CUR_USPL2]}]+="$quoted "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[ALIASES___dtrace/_dtrace]+="$quoted "
    done

    # Actual alias.
    builtin alias "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-zle [[[.
# Function defined to hijack plugin's calls to the `zle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-zle() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Zle $*"

    # Remember to perform the actual zle call.
    typeset -a pos
    pos=( "$@" )

    builtin set -- "${@:#--}"

    # Try to catch game-changing "-N".
    if [[ ( $1 = -N && ( $# = 2 || $# = 3 ) ) || ( $1 = -C && $# = 4 ) ]]; then
            # Hooks.
            if [[ ${ZINIT_ZLE_HOOKS_LIST[$2]} = 1 ]]; then
                local quoted="$2"
                quoted="${(q)quoted}"
                # Remember only when load is in progress (it can be dstart that leads execution here).
                [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_DELETE__${ZINIT[CUR_USPL2]}]+="$quoted "
                # Remember for dtrace.
                [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
            # These will be saved and restored.
            elif (( ${+widgets[$2]} )); then
                # Have to remember original widget "$2" and
                # the copy that it's going to be done.
                local widname="$2" targetfun="${${${(M)1:#-C}:+$4}:-$3}"
                local completion_widget="${${(M)1:#-C}:+$3}"
                local saved_widcontents="${widgets[$widname]}"

                widname="${(q)widname}"
                completion_widget="${(q)completion_widget}"
                targetfun="${(q)targetfun}"
                saved_widcontents="${(q)saved_widcontents}"
                local quoted="$1 $widname $completion_widget $targetfun $saved_widcontents"
                quoted="${(q)quoted}"
                # Remember only when load is in progress (it can be dstart that leads execution here).
                [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_SAVED__${ZINIT[CUR_USPL2]}]+="$quoted "
                # Remember for dtrace.
                [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_SAVED___dtrace/_dtrace]+="$quoted "
             # These will be deleted.
             else
                 .zinit-add-report "${ZINIT[CUR_USPL2]}" "Note: a new widget created via zle -N: \`$2'"
                 local quoted="$2"
                 quoted="${(q)quoted}"
                 # Remember only when load is in progress (it can be dstart that leads execution here).
                 [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_DELETE__${ZINIT[CUR_USPL2]}]+="$quoted "
                 # Remember for dtrace.
                 [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
             fi
    fi

    # Actual zle.
    builtin zle "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-compdef [[[
# Function defined to hijack plugin's calls to the `compdef' function.
# The hijacking is not only for reporting, but also to save compdef
# calls so that `compinit' can be called after loading plugins.
:zinit-tmp-subst-compdef() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Saving \`compdef $*' for replay"
    ZINIT_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" )

    return 0 # testable
} # ]]]
# FUNCTION: .zinit-tmp-subst-on [[[
# Turn on temporary substituting of functions of builtins and functions according to passed
# mode ("load", "light", "light-b" or "compdef"). The temporary substituting of functions is
# to gather report data, and to hijack 'autoload', 'bindkey' and 'compdef' calls.
.zinit-tmp-subst-on() {
    local mode="$1"

    # Enable temporary substituting of functions only once.
    #
    # One could expect possibility of widening of temporary substituting of functions, however
    # such sequence doesn't exist, e.g. "light" then "load"/"dtrace", "compdef" then "load"/
    # "dtrace", "light" then "compdef", "compdef" then "light".
    #
    # It is always "dtrace" then "load" (i.e. dtrace then load) "dtrace" then "light" (i.e.:
    # dtrace then light load) "dtrace" then "compdef" (i.e.: dtrace then snippet).
    [[ ${ZINIT[TMP_SUBST]} != inactive ]] && builtin return 0

    ZINIT[TMP_SUBST]="$mode"

    # The point about backuping is: does the key exist in functions array.
    # If it does exist, then it will also exist as ZINIT[bkp-*].

    # Defensive code, shouldn't be needed.
    builtin unset "ZINIT[bkp-autoload]" "ZINIT[bkp-compdef]"  # 0, E.

    if [[ $mode != compdef ]]; then
        # 0. Used, but not in temporary restoration, which doesn't happen for autoload.
        (( ${+functions[autoload]} )) && ZINIT[bkp-autoload]="${functions[autoload]}"
        functions[autoload]=':zinit-tmp-subst-autoload "$@";'
    fi

    # E. Always shade compdef.
    (( ${+functions[compdef]} )) && ZINIT[bkp-compdef]="${functions[compdef]}"
    functions[compdef]=':zinit-tmp-subst-compdef "$@";'

    # Temporarily replace `source' if subst'' given.
    if [[ -n ${ICE[subst]} ]] {
        (( ${+functions[source]} )) && ZINIT[bkp-source]="${functions[source]}"
        (( ${+functions[.]} )) && ZINIT[bkp-.]="${functions[.]}"
        (( ${+functions[.zinit-service]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-additional.zsh"
        functions[source]=':zinit-tmp-subst-source "$@";'
        functions[.]=':zinit-tmp-subst-source "$@";'
    }

    # Light and compdef temporary substituting of functions stops here. Dtrace and load go on.
    [[ ( $mode = light && ${+ICE[trackbinds]} -eq 0 ) || $mode = compdef ]] && return 0
... truncated; 2,551 more lines
.claude/worktrees/agent-ae3722fc4bdbaa34b/tests/recorder_corpus/zinit/zinit.zsh — 3,351 LOC
#
# zdharma-continuum/zinit/zinit.zsh
# Copyright (c) 2016-2021 Sebastian Gniazdowski
# Copyright (c) 2021-2023 zdharma-continuum
# Homepage: https://github.com/zdharma-continuum/zinit
# License: MIT License
#

#
# Main state variables.
#

typeset -gaH ZINIT_REGISTERED_PLUGINS ZINIT_TASKS ZINIT_RUN
typeset -ga zsh_loaded_plugins
if (( !${#ZINIT_TASKS} )) { ZINIT_TASKS=( "<no-data>" ); }
# Snippets loaded, url -> file name.
typeset -gAH ZINIT ZINIT_SNIPPETS ZINIT_REPORTS ZINIT_ICES ZINIT_SICE ZINIT_CUR_BIND_MAP ZINIT_EXTS ZINIT_EXTS2
typeset -gaH ZINIT_COMPDEF_REPLAY

# Compatibility with pre-rename project (Zplugin).
typeset -gAH ZPLGM
ZINIT=( "${(kv)ZPLGM[@]}" "${(kv)ZINIT[@]}" )
unset ZPLGM

#
# Common needed values.
#

[[ ! -e ${ZINIT[BIN_DIR]}/zinit.zsh ]] && ZINIT[BIN_DIR]=

# Respect the plugin standard too.
ZINIT[ZERO]="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
[[ ! -o functionargzero || ${options[posixargzero]} = on || ${ZINIT[ZERO]} != */* ]] && ZINIT[ZERO]="${(%):-%N}"

: ${ZINIT[BIN_DIR]:="${ZINIT[ZERO]:h}"}
[[ ${ZINIT[BIN_DIR]} = \~* ]] && ZINIT[BIN_DIR]=${~ZINIT[BIN_DIR]}

# Make ZINIT[BIN_DIR] path absolute.
ZINIT[BIN_DIR]="${${(M)ZINIT[BIN_DIR]:#/*}:-$PWD/${ZINIT[BIN_DIR]}}"

# Final test of ZINIT[BIN_DIR].
if [[ ! -e ${ZINIT[BIN_DIR]}/zinit.zsh ]]; then
    builtin print -P "%F{196}Could not establish ZINIT[BIN_DIR] hash field. It should point where Zinit's Git repository is.%f"
    return 1
fi

# User can override ZINIT[HOME_DIR].
if [[ -z ${ZINIT[HOME_DIR]} ]]; then
    # Search for zinit home in the usual locations
    if [[ -d ${XDG_DATA_HOME:-${HOME}/.local/share}/zinit ]]; then
        ZINIT[HOME_DIR]="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
    elif [[ -d $HOME/.zinit ]]; then
        ZINIT[HOME_DIR]="$HOME/.zinit"
    elif [[ -d ${ZDOTDIR:-$HOME}/.zinit ]]; then
        ZINIT[HOME_DIR]="${ZDOTDIR:-$HOME}/.zinit"
    elif [[ -d $HOME/.zplugin ]]; then
        ZINIT[HOME_DIR]="$HOME/.zplugin"
    elif [[ -d ${ZDOTDIR:-$HOME}/.zplugin ]]; then
        ZINIT[HOME_DIR]="${ZDOTDIR:-$HOME}/.zplugin"
    else
        ZINIT[HOME_DIR]="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
    fi
fi

if [[ -z ${ZINIT[LIST_COMMAND]} ]]; then
    if (( ${+commands[eza]} )); then
        ZINIT[LIST_COMMAND]='eza --color=always --tree --icons -L3'
    elif (( ${+commands[exa]} )); then
        ZINIT[LIST_COMMAND]='exa --color=always --tree --icons -L3'
    elif (( ${+commands[tree]} )); then
        ZINIT[LIST_COMMAND]='tree -L 3 -C --charset utf-8'
    else
        ZINIT[LIST_COMMAND]='ls --tree'
    fi
fi

ZINIT[ice-list]="\
\!bash|\!csh|\!ksh|\!sh|\
aliases|as|atclone|atdelete|atinit|atload|atpull|autoload|\
bash|binary|bindmap|blockf|bpick|build|\
cloneonly|cloneopts|cmake|compile|completions|configure|countdown|cp|csh|\
debug|depth|\
extract|\
from|git|\
has|\
id-as|if|install|is-snippet|\
ksh|\
light-mode|link|load|lucid|\
make|multisrc|mv|nocd|nocompile|nocompletions|notify|null|\
on-update-of|opts|\
pack|param|pick|proto|ps-on-unload|ps-on-update|pullopts|\
reset|reset-prompt|run-atpull|\
service|sh|silent|src|subscribe|subst|svn|\
teleid|trackbinds|trigger-load|\
unload|\
ver|verbose|\
wait|wrap"
ZINIT[nval-ice-list]="\
\!bash|\!csh|\!ksh|\!sh|\
aliases|\
bash|binary|blockf|\
cloneonly|cloneopts|cmake|configure|countdown|csh|\
debug|\
git|\
is-snippet|\
ksh|\
light-mode|lucid|\
make|\
nocd|nocompile|nocompletions|notify|null|\
pullopts|\
reset|run-atpull|\
sh|silent|\
trackbinds|\
verbose"
ZINIT[cmds]="\
add-fpath|\
bindkeys|\
cclear|cd|cdclear|cdisable|cdlist|cdreplay|cenable|changes|compile|compiled|compinit|completions|create|creinstall|csearch|cuninstall|\
delete|debug|\
edit|env-whitelist|\
fpath|\
glance|\
help|--help|-h|\
ice|\
light|load|\
man|module|\
plugins|\
recall|recently|report|run|\
self-update|snippet|snippets|srv|status|stress|\
times|\
uncompile|unload|update|\
version|\
zstatus"

# Can be customized.
: ${ZINIT[COMPLETIONS_DIR]:=${ZINIT[HOME_DIR]}/completions}
: ${ZINIT[MODULE_DIR]:=${ZINIT[HOME_DIR]}/module}
: ${ZINIT[PACKAGES_BRANCH]:=HEAD}
: ${ZINIT[PACKAGES_REPO]:=zdharma-continuum/zinit-packages}
: ${ZINIT[PLUGINS_DIR]:=${ZINIT[HOME_DIR]}/plugins}
: ${ZINIT[POLARIS_DIR]:=${ZINIT[HOME_DIR]}/polaris}
: ${ZINIT[SERVICES_DIR]:=${ZINIT[HOME_DIR]}/services}
: ${ZINIT[SNIPPETS_DIR]:=${ZINIT[HOME_DIR]}/snippets}
: ${ZINIT[ZPFX]:=${ZINIT[HOME_DIR]}/polaris}
typeset -g ZPFX
: ${ZPFX:=${ZINIT[ZPFX]}}
: ${ZINIT[ALIASES_OPT]::=${${options[aliases]:#off}:+1}}
: ${ZINIT[MAN_DIR]:=${ZPFX}/man}

ZINIT[PLUGINS_DIR]=${~ZINIT[PLUGINS_DIR]}   ZINIT[COMPLETIONS_DIR]=${~ZINIT[COMPLETIONS_DIR]}
ZINIT[SNIPPETS_DIR]=${~ZINIT[SNIPPETS_DIR]} ZINIT[SERVICES_DIR]=${~ZINIT[SERVICES_DIR]}

# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
  ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/zinit"
fi

export ZPFX=${~ZPFX} ZSH_CACHE_DIR="${ZSH_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/zinit}" \
    PMSPEC=0uUpiPsf
[[ -z ${path[(re)$ZPFX/bin]} ]] && [[ -d "$ZPFX/bin" ]] && path=( "$ZPFX/bin" "${path[@]}" )
[[ -z ${path[(re)$ZPFX/sbin]} ]] && [[ -d "$ZPFX/sbin" ]] && path=( "$ZPFX/sbin" "${path[@]}" )

hash -f
hash -d zinit=${ZINIT[HOME_DIR]}
hash -d plugins=${ZINIT[PLUGINS_DIR]}
hash -d zpfx=${ZINIT[HOME_DIR]}/polaris

# Add completions directory to fpath.
[[ -z ${fpath[(re)${ZINIT[COMPLETIONS_DIR]}]} ]] && fpath=( "${ZINIT[COMPLETIONS_DIR]}" "${fpath[@]}" )

[[ ! -d $ZSH_CACHE_DIR ]] && command mkdir -p "$ZSH_CACHE_DIR"
[[ -n ${ZINIT[ZCOMPDUMP_PATH]} ]] && ZINIT[ZCOMPDUMP_PATH]=${~ZINIT[ZCOMPDUMP_PATH]}

# Create "$ZSH_CACHE_DIR/completions" directory
[[ ! -d "$ZSH_CACHE_DIR/completions" ]] && command mkdir -p "$ZSH_CACHE_DIR/completions"
# Add "$ZSH_CACHE_DIR/completions" diretory to fpath
[[ -z ${fpath[(re)$ZSH_CACHE_DIR/completions]} ]] && fpath=( "$ZSH_CACHE_DIR/completions" "${fpath[@]}" )

ZINIT[UPAR]=";:^[[A;:^[OA;:\\e[A;:\\eOA;:${termcap[ku]/$'\e'/^\[};:${terminfo[kcuu1]/$'\e'/^\[};:"
ZINIT[DOWNAR]=";:^[[B;:^[OB;:\\e[B;:\\eOB;:${termcap[kd]/$'\e'/^\[};:${terminfo[kcud1]/$'\e'/^\[};:"
ZINIT[RIGHTAR]=";:^[[C;:^[OC;:\\e[C;:\\eOC;:${termcap[kr]/$'\e'/^\[};:${terminfo[kcuf1]/$'\e'/^\[};:"
ZINIT[LEFTAR]=";:^[[D;:^[OD;:\\e[D;:\\eOD;:${termcap[kl]/$'\e'/^\[};:${terminfo[kcub1]/$'\e'/^\[};:"

builtin autoload -Uz is-at-least
is-at-least 5.1 && ZINIT[NEW_AUTOLOAD]=1 || ZINIT[NEW_AUTOLOAD]=0
#is-at-least 5.4 && ZINIT[NEW_AUTOLOAD]=2

# Parameters [[[
# temporary substituting of functions
ZINIT[TMP_SUBST]=inactive ZINIT[DTRACE]=0 ZINIT[CUR_PLUGIN]=

# ice
declare -gA ZINIT_1MAP ZINIT_2MAP
ZINIT_1MAP=(
    OMZ:: https://github.com/ohmyzsh/ohmyzsh/trunk/
    OMZP:: https://github.com/ohmyzsh/ohmyzsh/trunk/plugins/
    OMZT:: https://github.com/ohmyzsh/ohmyzsh/trunk/themes/
    OMZL:: https://github.com/ohmyzsh/ohmyzsh/trunk/lib/
    PZT:: https://github.com/sorin-ionescu/prezto/trunk/
    PZTM:: https://github.com/sorin-ionescu/prezto/trunk/modules/
)
ZINIT_2MAP=(
    OMZ:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/
    OMZP:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/
    OMZT:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/themes/
    OMZL:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/lib/
    PZT:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/
    PZTM:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/modules/
)
# ]]]

# Init [[[
zmodload zsh/zutil || { builtin print -P "%F{196}zsh/zutil module is required, aborting Zinit set up.%f"; return 1; }
zmodload zsh/parameter || { builtin print -P "%F{196}zsh/parameter module is required, aborting Zinit set up.%f"; return 1; }
zmodload zsh/term{cap,info} 2>/dev/null
autoload -Uz colors && colors

if [[ -z $SOURCED && ( ${+terminfo} -eq 1 && -n ${terminfo[colors]} ) || ( ${+termcap} -eq 1 && -n ${termcap[Co]} ) ]]; then
  ZINIT+=(
    col-annex   $'\e[38;5;153m'         col-faint   $'\e[38;5;238m'         col-msg2    $'\e[38;5;172m'      col-quo     $'\e[1;38;5;33m'
    col-apo     $'\e[1;38;5;45m'        col-file    $'\e[3;38;5;117m'       col-msg3    $'\e[38;5;238m'      col-quos    $'\e[1;38;5;160m'
    col-aps     $'\e[38;5;117m'         col-flag    $'\e[1;3;38;5;79m'      col-nb      $'\e[22m'            col-rst     $'\e[0m'
    col-b       $'\e[1m'                col-func    $'\e[38;5;219m'         col-nit     $'\e[23m'            col-slight  $'\e[38;5;230m'
    col-b-lhi   $'\e[1m\e[38;5;75m'     col-glob    $'\e[38;5;227m'         col-nl      $'\n'                col-st      $'\e[9m'
    col-b-warn  $'\e[1;38;5;214m'       col-happy   $'\e[1m\e[38;5;82m'     col-note    $'\e[38;5;148m'      col-tab     $' \t '
    col-bapo    $'\e[1;38;5;220m'       col-hi      $'\e[1m\e[38;5;183m'    col-nst     $'\e[29m'            col-term    $'\e[38;5;185m'
    col-baps    $'\e[1;38;5;82m'        col-ice     $'\e[38;5;39m'          col-nu      $'\e[24m'            col-th-bar  $'\e[38;5;82m'
    col-bar     $'\e[38;5;82m'          col-id-as   $'\e[4;38;5;220m'       col-num     $'\e[3;38;5;155m'    col-time    $'\e[38;5;220m'
    col-bcmd    $'\e[38;5;220m'         col-info    $'\e[38;5;82m'          col-obj     $'\e[38;5;218m'      col-txt     $'\e[38;5;254m'
    col-bspc    $'\b'                   col-info2   $'\e[38;5;227m'         col-obj2    $'\e[38;5;118m'      col-u       $'\e[4m'
    col-cmd     $'\e[38;5;82m'          col-info3   $'\e[1m\e[38;5;227m'    col-ok      $'\e[38;5;220m'      col-u-warn  $'\e[4;38;5;214m'
    col-data    $'\e[38;5;82m'          col-it      $'\e[3m'                col-opt     $'\e[38;5;219m'      col-uname   $'\e[1;4m\e[35m'
    col-data2   $'\e[38;5;117m'         col-keyword $'\e[32m'               col-p       $'\e[38;5;81m'       col-uninst  $'\e[38;5;118m'
    col-dir     $'\e[3;38;5;153m'       col-lhi     $'\e[38;5;81m'          col-pkg     $'\e[1;3;38;5;27m'   col-url     $'\e[38;5;75m'
    col-ehi     $'\e[1m\e[38;5;210m'    col-meta    $'\e[38;5;57m'          col-pname   $'\e[1;4m\e[32m'     col-var     $'\e[38;5;81m'
    col-error   $'\e[1m\e[38;5;204m'    col-meta2   $'\e[38;5;147m'         col-pre     $'\e[38;5;135m'      col-version $'\e[3;38;5;87m'
    col-failure $'\e[38;5;204m'         col-msg     $'\e[0m'                col-profile $'\e[38;5;148m'      col-warn    $'\e[38;5;214m'

    col-dbg $'\e[2m\e[38;47;107m'"[debug]"$'\e[0m'
    col-e $'\e[1m\e[38;5;204m'"Error"$'\e[0m'":"
    col-i $'\e[1m\e[38;5;82m'"==>"$'\e[0m'
    col-m $'\e[38;5;4m'"==>"$'\e[0m'
    col-w $'\e[1m\e[38;5;214m'"Warning"$'\e[0m'":"

    col--…   "${${${(M)LANG:#*UTF-8*}:+⋯⋯}:-···}"    col-lr "${${${(M)LANG:#*UTF-8*}:+↔}:-"«-»"}"
    col-ndsh "${${${(M)LANG:#*UTF-8*}:+–}:-}"        col-…  "${${${(M)LANG:#*UTF-8*}:+…}:-...}"

    col-mdsh  $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+–}:--}"$'\e[0m'
    col-mmdsh $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+――}:--}"$'\e[0m'

    col-↔     ${${${(M)LANG:#*UTF-8*}:+$'\e[38;5;82m↔\e[0m'}:-$'\e[38;5;82m«-»\e[0m'}
  )
  if [[ ( ${+terminfo} -eq 1 && ${terminfo[colors]} -ge 256 ) || ( ${+termcap} -eq 1 && ${termcap[Co]} -ge 256 ) ]]; then
    ZINIT+=( col-pname $'\e[1;4m\e[38;5;39m' col-uname  $'\e[1;4m\e[38;5;207m' )
  fi
fi

# Hooks
typeset -gAH ZINIT_ZLE_HOOKS_LIST
ZINIT_ZLE_HOOKS_LIST=(
    zle-isearch-exit 1
    zle-isearch-update 1
    zle-line-pre-redraw 1
    zle-line-init 1
    zle-line-finish 1
    zle-history-line-set 1
    zle-keymap-select 1
    paste-insert 1
)
builtin setopt noaliases
# ]]]

#
# Temporary substituting of functions-related functions.
#

# FUNCTION: :zinit-reload-and-run [[[
# Marks given function ($3) for autoloading, and executes it triggering the
# load. $1 is the fpath dedicated to the function, $2 are autoload options.
# This function replaces "autoload -X", because using that on older Zsh
# versions causes problems with traps.
#
# So basically one creates function stub that calls :zinit-reload-and-run()
# instead of "autoload -X".
#
# Author: Bart Schaefer
#
# $1 - FPATH dedicated to function
# $2 - autoload options
# $3 - function name (one that needs autoloading)
:zinit-reload-and-run() {
    local fpath_prefix="$1" autoload_opts="$2" func="$3"
    shift 3

    # Unfunction caller function (its name is given).
    unfunction -- "$func"

    local -a ___fpath
    ___fpath=( ${fpath[@]} )
    local -a +h fpath
    # See #127.
    [[ $FPATH != *${${(@0)fpath_prefix}[1]}* ]] && \
        fpath=( ${(@0)fpath_prefix} ${___fpath[@]} )

    # After this the function exists again.
    builtin autoload ${(s: :)autoload_opts} -- "$func"

    # User wanted to call the function, not only load it.
    "$func" "$@"
} # ]]]
# FUNCTION: :zinit-tmp-subst-autoload [[[
# Hijack plugin's calls to the 'autoload' builtin.
#
# The hijacking gathers report data and runs custom `autoload' function, that doesn't need FPATH.
:zinit-tmp-subst-autoload() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt extendedglob warncreateglobal typesetsilent rcquotes
    local -a opts opts2 custom reply
    local func

    zparseopts -D -E -M -a opts ${(s::):-RTUXdkmrtWzwC} I+=opts2 S+:=custom

    builtin set -- ${@:#--}

    # Process the id-as''/teleid'' to get the plugin dir.
    .zinit-any-to-user-plugin $ZINIT[CUR_USPL2]
    [[ $reply[1] = % ]] && \
        local PLUGIN_DIR="$reply[2]" || \
        local PLUGIN_DIR="$ZINIT[PLUGINS_DIR]/${reply[1]:+$reply[1]---}${reply[2]//\//---}"


    # "fpath elements" ----  those elements that lie inside the plug directory.
    local -a fpath_elements
    fpath_elements=( ${fpath[(r)$PLUGIN_DIR/*]} )

    # Add a function subdirectory to items, if any (this action is
    # according to the Plug Standard version 1.07 and later).
    [[ -d $PLUGIN_DIR/functions ]] && fpath_elements+=( "$PLUGIN_DIR"/functions )

    if (( ${+opts[(r)-X]} )); then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: Failed autoload ${(j: :)opts[@]} $*"
        +zi-log -u2 "{error}builtin autoload required for {obj}${(j: :)opts[@]}{error} option(s)"
        return 1
    fi
    if (( ${+opts[(r)-w]} )); then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "-w-Autoload ${(j: :)opts[@]} ${(j: :)@}"
        fpath+=( $PLUGIN_DIR )
        builtin autoload ${opts[@]} "$@"
        return $?
    fi
    if [[ -n ${(M)@:#+X} ]]; then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Autoload +X ${opts:+${(j: :)opts[@]} }${(j: :)${@:#+X}}"
        local +h FPATH=$PLUGINS_DIR${fpath_elements:+:${(j.:.)fpath_elements[@]}}:$FPATH
        local +h -a fpath
        fpath=( $PLUGIN_DIR $fpath_elements $fpath )
        builtin autoload +X ${opts[@]} "${@:#+X}"
        return $?
    fi

    for func; do
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Autoload $func${opts:+ with options ${(j: :)opts[@]}}"
    done

    integer count retval
    for func; do
        # Real autoload doesn't touch function if it already exists.
        # Author of the idea of FPATH-clean autoloading: Bart Schaefer.
        if (( ${+functions[$func]} != 1 )) {
            builtin setopt noaliases
            if [[ $func == /* ]] && is-at-least 5.4; then
                builtin autoload ${opts[@]} $func
                return $?
            elif [[ $func == /* ]]; then
                if [[ $ZINIT[MUTE_WARNINGS] != (1|true|on|yes) && \
                        -z $ZINIT[WARN_SHOWN_FOR_$ZINIT[CUR_USPL2]] ]]; then
                    +zi-log "{u-warn}Warning{b-warn}: {rst}the plugin {pid}$ZINIT[CUR_USPL2]" \
                        "{rst}is using autoload functions specified by their absolute path," \
                        "which is not supported by this Zsh version ({↔} {version}$ZSH_VERSION{rst}," \
                        "required is Zsh >= {version}5.4{rst})." \
                        "{nl}A fallback mechanism has been applied, which works well only" \
                        "for functions in the plugin {u}{slight}main{rst} directory." \
                        "{nl}(To mute this message, set" \
                        "{var}\$ZINIT[MUTE_WARNINGS]{rst} to a truth value.)"
                    ZINIT[WARN_SHOWN_FOR_$ZINIT[CUR_USPL2]]=1
                fi

                # Workaround
                func=$func:t
            fi
            if [[ ${ZINIT[NEW_AUTOLOAD]} = 2 ]]; then
                builtin autoload ${opts[@]} "$PLUGIN_DIR/$func"
                retval=$?
            elif [[ ${ZINIT[NEW_AUTOLOAD]} = 1 ]]; then
                if (( ${+opts[(r)-C]} )) {
                    local pth nl=$'\n' sel=""
                    for pth ( $PLUGIN_DIR $fpath_elements $fpath ) {
                        [[ -f $pth/$func ]] && { sel=$pth; break; }
                    }
                    if [[ -z $sel ]] {
                        +zi-log '{u-warn}zinit{b-warn}:{error} Couldn''t find autoload function{ehi}:' \
                            "{apo}\`{file}${func}{apo}\`{error} anywhere in {var}\$fpath{error}."
                            retval=1
                    } else {
                        eval "function ${(q)${custom[++count*2]}:-$func} {
                            local body=\"\$(<${(qqq)sel}/${(qqq)func})\" body2
                            () { setopt localoptions extendedglob
                                 body2=\"\${body##[[:space:]]#${func}[[:blank:]]#\(\)[[:space:]]#\{}\"
                                 [[ \$body2 != \$body ]] && \
                                    body2=\"\${body2%\}[[:space:]]#([$nl]#([[:blank:]]#\#[^$nl]#((#e)|[$nl]))#)#}\"
                            }

                            functions[${${(q)custom[count*2]}:-$func}]=\"\$body2\"
                            ${(q)${custom[count*2]}:-$func} \"\$@\"
                        }"
                        retval=$?
                    }
                } else {
                    functions[$func]="
                        local -a fpath
                        fpath=( ${(qqq)PLUGIN_DIR} ${(qqq@)fpath_elements} ${(qqq@)fpath} )
                        builtin autoload -X ${(j: :)${(q-)opts[@]}}
                    "
                    retval=$?
                }
            else
                eval "function ${(q)func} {
                    :zinit-reload-and-run ${(qqq)PLUGIN_DIR}"$'\0'"${(pj,\0,)${(qqq)fpath_elements[@]}} ${(qq)opts[*]} ${(q)func} "'"$@"
                }'
                retval=$?
            fi
            (( ZINIT[ALIASES_OPT] )) && builtin setopt aliases
        }
        if (( ${+opts2[(r)-I]} )) {
            ${custom[count*2]:-$func}
            retval=$?
        }
    done

    return $retval
} # ]]]
# FUNCTION: :zinit-tmp-subst-bindkey [[[
# Function defined to hijack plugin's calls to the `bindkey' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-bindkey() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt extendedglob warncreateglobal typesetsilent noshortloops

    is-at-least 5.3 && \
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Bindkey ${(j: :)${(q+)@}}" || \
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Bindkey ${(j: :)${(q)@}}"

    # Remember to perform the actual bindkey call.
    typeset -a pos
    pos=( "$@" )

    # Check if we have regular bindkey call, i.e.
    # with no options or with -s, plus possible -M
    # option.
    local -A opts
    zparseopts -A opts -D ${(s::):-lLdDAmrsevaR} M: N:

    if (( ${#opts} == 0 ||
        ( ${#opts} == 1 && ${+opts[-M]} ) ||
        ( ${#opts} == 1 && ${+opts[-R]} ) ||
        ( ${#opts} == 1 && ${+opts[-s]} ) ||
        ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-s]} ) ||
        ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-R]} )
    )); then
        local string="${(q)1}" widget="${(q)2}"
        local quoted

        if [[ -n ${ICE[bindmap]} && ${ZINIT_CUR_BIND_MAP[empty]} -eq 1 ]]; then
            local -a pairs
            pairs=( "${(@s,;,)ICE[bindmap]}" )
            if [[ -n ${(M)pairs:#*\\(#e)} ]] {
                local prev
                pairs=( ${pairs[@]//(#b)((*)\\(#e)|(*))/${match[3]:+${prev:+$prev\;}}${match[3]}${${prev::=${match[2]:+${prev:+$prev\;}}${match[2]}}:+}} )
            }
            pairs=( "${(@)${(@)${(@s:->:)pairs}##[[:space:]]##}%%[[:space:]]##}" )
            ZINIT_CUR_BIND_MAP=( empty 0 )
            (( ${#pairs} > 1 && ${#pairs[@]} % 2 == 0 )) && ZINIT_CUR_BIND_MAP+=( "${pairs[@]}" )
        fi

        local bmap_val="${ZINIT_CUR_BIND_MAP[${1}]}"
        if (( !ZINIT_CUR_BIND_MAP[empty] )) {
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[${(qqq)1}]}"
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[${(qqq)${(Q)1}}]}"
            [[ -z $bmap_val ]] && { bmap_val="${ZINIT_CUR_BIND_MAP[!${(qqq)1}]}"; integer val=1; }
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[!${(qqq)${(Q)1}}]}"
        }
        if [[ -n $bmap_val ]]; then
            string="${(q)bmap_val}"
            if (( val )) {
                [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
            } else {
                [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
            }
            .zinit-add-report "${ZINIT[CUR_USPL2]}" ":::Bindkey: combination <$1> changed to <$bmap_val>${${(M)bmap_val:#hold}:+, i.e. ${ZINIT[col-error]}unmapped${ZINIT[col-rst]}}"
            ((1))
        elif [[ ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[UPAR]}} && -n ${${ZINIT[UPAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[DOWNAR]}} && -n ${${ZINIT[DOWNAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[RIGHTAR]}} && -n ${${ZINIT[RIGHTAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[LEFTAR]}} && -n ${${ZINIT[LEFTAR]}[(r);:${(q)1};:]} )
        ]]; then
            string="${(q)bmap_val}"
            if (( val )) {
                [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
            } else {
                [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
            }
            .zinit-add-report "${ZINIT[CUR_USPL2]}" ":::Bindkey: combination <$1> recognized as cursor-key and changed to <${bmap_val}>${${(M)bmap_val:#hold}:+, i.e. ${ZINIT[col-error]}unmapped${ZINIT[col-rst]}}"
        fi
        [[ $bmap_val = hold ]] && return 0

        local prev="${(q)${(s: :)$(builtin bindkey ${(Q)string})}[-1]#undefined-key}"

        # "-M map" given?
        if (( ${+opts[-M]} )); then
            local Mopt=-M
            local Marg="${opts[-M]}"

            Mopt="${(q)Mopt}"
            Marg="${(q)Marg}"

            quoted="$string $widget $prev $Mopt $Marg"
        else
            quoted="$string $widget $prev"
        fi

        # -R given?
        if (( ${+opts[-R]} )); then
            local Ropt=-R
            Ropt="${(q)Ropt}"

            if (( ${+opts[-M]} )); then
                quoted="$quoted $Ropt"
            else
                # Two empty fields for non-existent -M arg.
                local space=_
                space="${(q)space}"
                quoted="$quoted $space $space $Ropt"
            fi
        fi

        quoted="${(q)quoted}"

        # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "
    else
        # bindkey -A newkeymap main?
        # Negative indices for KSH_ARRAYS immunity.
        if [[ ${#opts} -eq 1 && ${+opts[-A]} = 1 && ${#pos} = 3 && ${pos[-1]} = main && ${pos[-2]} != -A ]]; then
            # Save a copy of main keymap.
            (( ZINIT[BINDKEY_MAIN_IDX] = ${ZINIT[BINDKEY_MAIN_IDX]:-0} + 1 ))
            local pname="${ZINIT[CUR_PLUGIN]:-_dtrace}"
            local name="${(q)pname}-main-${ZINIT[BINDKEY_MAIN_IDX]}"
            builtin bindkey -N "$name" main

            # Remember occurence of main keymap substitution, to revert on unload.
            local keys=_ widget=_ prev= optA=-A mapname="${name}" optR=_
            local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optA} ${(q)mapname} ${(q)optR}"
            quoted="${(q)quoted}"

            # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
            [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
            [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "

            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: keymap \`main' copied to \`${name}' because of \`${pos[-2]}' substitution"
        # bindkey -N newkeymap [other].
        elif [[ ${#opts} -eq 1 && ${+opts[-N]} = 1 ]]; then
            local Nopt=-N
            local Narg="${opts[-N]}"

            local keys=_ widget=_ prev= optN=-N mapname="${Narg}" optR=_
            local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optN} ${(q)mapname} ${(q)optR}"
            quoted="${(q)quoted}"

            # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
            [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
            [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "
        else
            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: last bindkey used non-typical options: ${(kv)opts[*]}"
        fi
    fi

    # Actual bindkey.
    builtin bindkey "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-zstyle [[[
# Function defined to hijack plugin's calls to the `zstyle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-zstyle() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob nowarncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Zstyle $*"

    # Remember in order to perform the actual zstyle call.
    typeset -a pos
    pos=( "$@" )

    # Check if we have regular zstyle call, i.e.
    # with no options or with -e.
    local -a opts
    zparseopts -a opts -D ${(s::):-eLdgabsTtm}

    if [[ ${#opts} -eq 0 || ( ${#opts} -eq 1 && ${+opts[(r)-e]} = 1 ) ]]; then
        # Have to quote $1, then $2, then concatenate them, then quote them again.
        local pattern="${(q)1}" style="${(q)2}"
        local ps="$pattern $style"
        ps="${(q)ps}"

        # Remember the zstyle, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[ZSTYLES__${ZINIT[CUR_USPL2]}]+="$ps "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[ZSTYLES___dtrace/_dtrace]+=$ps
    else
        if [[ ! ${#opts[@]} = 1 && ( ${+opts[(r)-s]} = 1 || ${+opts[(r)-b]} = 1 || ${+opts[(r)-a]} = 1 ||
              ${+opts[(r)-t]} = 1 || ${+opts[(r)-T]} = 1 || ${+opts[(r)-m]} = 1 )
        ]]; then
            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: last zstyle used non-typical options: ${opts[*]}"
        fi
    fi

    # Actual zstyle.
    builtin zstyle "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-alias [[[
# Function defined to hijack plugin's calls to the `alias' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-alias() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Alias $*"

    # Remember to perform the actual alias call.
    typeset -a pos
    pos=( "$@" )

    local -a opts
    zparseopts -a opts -D ${(s::):-gs}

    local a quoted tmp
    for a in "$@"; do
        local aname="${a%%[=]*}"
        local avalue="${a#*=}"

        # Check if alias is to be redefined.
        (( ${+aliases[$aname]} )) && .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: redefining alias \`${aname}', previous value: ${aliases[$aname]}"

        local bname=${(q)aliases[$aname]}
        aname="${(q)aname}"

        if (( ${+opts[(r)-s]} )); then
            tmp=-s
            tmp="${(q)tmp}"
            quoted="$aname $bname $tmp"
        elif (( ${+opts[(r)-g]} )); then
            tmp=-g
            tmp="${(q)tmp}"
            quoted="$aname $bname $tmp"
        else
            quoted="$aname $bname"
        fi

        quoted="${(q)quoted}"

        # Remember the alias, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[ALIASES__${ZINIT[CUR_USPL2]}]+="$quoted "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[ALIASES___dtrace/_dtrace]+="$quoted "
    done

    # Actual alias.
    builtin alias "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-zle [[[.
# Function defined to hijack plugin's calls to the `zle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-zle() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Zle $*"

    # Remember to perform the actual zle call.
    typeset -a pos
    pos=( "$@" )

    builtin set -- "${@:#--}"

    # Try to catch game-changing "-N".
    if [[ ( $1 = -N && ( $# = 2 || $# = 3 ) ) || ( $1 = -C && $# = 4 ) ]]; then
            # Hooks.
            if [[ ${ZINIT_ZLE_HOOKS_LIST[$2]} = 1 ]]; then
                local quoted="$2"
                quoted="${(q)quoted}"
                # Remember only when load is in progress (it can be dstart that leads execution here).
                [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_DELETE__${ZINIT[CUR_USPL2]}]+="$quoted "
                # Remember for dtrace.
                [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
            # These will be saved and restored.
            elif (( ${+widgets[$2]} )); then
                # Have to remember original widget "$2" and
                # the copy that it's going to be done.
                local widname="$2" targetfun="${${${(M)1:#-C}:+$4}:-$3}"
                local completion_widget="${${(M)1:#-C}:+$3}"
                local saved_widcontents="${widgets[$widname]}"

                widname="${(q)widname}"
                completion_widget="${(q)completion_widget}"
                targetfun="${(q)targetfun}"
                saved_widcontents="${(q)saved_widcontents}"
                local quoted="$1 $widname $completion_widget $targetfun $saved_widcontents"
                quoted="${(q)quoted}"
                # Remember only when load is in progress (it can be dstart that leads execution here).
                [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_SAVED__${ZINIT[CUR_USPL2]}]+="$quoted "
                # Remember for dtrace.
                [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_SAVED___dtrace/_dtrace]+="$quoted "
             # These will be deleted.
             else
                 .zinit-add-report "${ZINIT[CUR_USPL2]}" "Note: a new widget created via zle -N: \`$2'"
                 local quoted="$2"
                 quoted="${(q)quoted}"
                 # Remember only when load is in progress (it can be dstart that leads execution here).
                 [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_DELETE__${ZINIT[CUR_USPL2]}]+="$quoted "
                 # Remember for dtrace.
                 [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
             fi
    fi

    # Actual zle.
    builtin zle "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-compdef [[[
# Function defined to hijack plugin's calls to the `compdef' function.
# The hijacking is not only for reporting, but also to save compdef
# calls so that `compinit' can be called after loading plugins.
:zinit-tmp-subst-compdef() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Saving \`compdef $*' for replay"
    ZINIT_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" )

    return 0 # testable
} # ]]]
# FUNCTION: .zinit-tmp-subst-on [[[
# Turn on temporary substituting of functions of builtins and functions according to passed
# mode ("load", "light", "light-b" or "compdef"). The temporary substituting of functions is
# to gather report data, and to hijack 'autoload', 'bindkey' and 'compdef' calls.
.zinit-tmp-subst-on() {
    local mode="$1"

    # Enable temporary substituting of functions only once.
    #
    # One could expect possibility of widening of temporary substituting of functions, however
    # such sequence doesn't exist, e.g. "light" then "load"/"dtrace", "compdef" then "load"/
    # "dtrace", "light" then "compdef", "compdef" then "light".
    #
    # It is always "dtrace" then "load" (i.e. dtrace then load) "dtrace" then "light" (i.e.:
    # dtrace then light load) "dtrace" then "compdef" (i.e.: dtrace then snippet).
    [[ ${ZINIT[TMP_SUBST]} != inactive ]] && builtin return 0

    ZINIT[TMP_SUBST]="$mode"

    # The point about backuping is: does the key exist in functions array.
    # If it does exist, then it will also exist as ZINIT[bkp-*].

    # Defensive code, shouldn't be needed.
    builtin unset "ZINIT[bkp-autoload]" "ZINIT[bkp-compdef]"  # 0, E.

    if [[ $mode != compdef ]]; then
        # 0. Used, but not in temporary restoration, which doesn't happen for autoload.
        (( ${+functions[autoload]} )) && ZINIT[bkp-autoload]="${functions[autoload]}"
        functions[autoload]=':zinit-tmp-subst-autoload "$@";'
    fi

    # E. Always shade compdef.
    (( ${+functions[compdef]} )) && ZINIT[bkp-compdef]="${functions[compdef]}"
    functions[compdef]=':zinit-tmp-subst-compdef "$@";'

    # Temporarily replace `source' if subst'' given.
    if [[ -n ${ICE[subst]} ]] {
        (( ${+functions[source]} )) && ZINIT[bkp-source]="${functions[source]}"
        (( ${+functions[.]} )) && ZINIT[bkp-.]="${functions[.]}"
        (( ${+functions[.zinit-service]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-additional.zsh"
        functions[source]=':zinit-tmp-subst-source "$@";'
        functions[.]=':zinit-tmp-subst-source "$@";'
    }

    # Light and compdef temporary substituting of functions stops here. Dtrace and load go on.
    [[ ( $mode = light && ${+ICE[trackbinds]} -eq 0 ) || $mode = compdef ]] && return 0
... truncated; 2,551 more lines
tests/recorder_corpus/zinit/zinit.zsh — 3,351 LOC
#
# zdharma-continuum/zinit/zinit.zsh
# Copyright (c) 2016-2021 Sebastian Gniazdowski
# Copyright (c) 2021-2023 zdharma-continuum
# Homepage: https://github.com/zdharma-continuum/zinit
# License: MIT License
#

#
# Main state variables.
#

typeset -gaH ZINIT_REGISTERED_PLUGINS ZINIT_TASKS ZINIT_RUN
typeset -ga zsh_loaded_plugins
if (( !${#ZINIT_TASKS} )) { ZINIT_TASKS=( "<no-data>" ); }
# Snippets loaded, url -> file name.
typeset -gAH ZINIT ZINIT_SNIPPETS ZINIT_REPORTS ZINIT_ICES ZINIT_SICE ZINIT_CUR_BIND_MAP ZINIT_EXTS ZINIT_EXTS2
typeset -gaH ZINIT_COMPDEF_REPLAY

# Compatibility with pre-rename project (Zplugin).
typeset -gAH ZPLGM
ZINIT=( "${(kv)ZPLGM[@]}" "${(kv)ZINIT[@]}" )
unset ZPLGM

#
# Common needed values.
#

[[ ! -e ${ZINIT[BIN_DIR]}/zinit.zsh ]] && ZINIT[BIN_DIR]=

# Respect the plugin standard too.
ZINIT[ZERO]="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
[[ ! -o functionargzero || ${options[posixargzero]} = on || ${ZINIT[ZERO]} != */* ]] && ZINIT[ZERO]="${(%):-%N}"

: ${ZINIT[BIN_DIR]:="${ZINIT[ZERO]:h}"}
[[ ${ZINIT[BIN_DIR]} = \~* ]] && ZINIT[BIN_DIR]=${~ZINIT[BIN_DIR]}

# Make ZINIT[BIN_DIR] path absolute.
ZINIT[BIN_DIR]="${${(M)ZINIT[BIN_DIR]:#/*}:-$PWD/${ZINIT[BIN_DIR]}}"

# Final test of ZINIT[BIN_DIR].
if [[ ! -e ${ZINIT[BIN_DIR]}/zinit.zsh ]]; then
    builtin print -P "%F{196}Could not establish ZINIT[BIN_DIR] hash field. It should point where Zinit's Git repository is.%f"
    return 1
fi

# User can override ZINIT[HOME_DIR].
if [[ -z ${ZINIT[HOME_DIR]} ]]; then
    # Search for zinit home in the usual locations
    if [[ -d ${XDG_DATA_HOME:-${HOME}/.local/share}/zinit ]]; then
        ZINIT[HOME_DIR]="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
    elif [[ -d $HOME/.zinit ]]; then
        ZINIT[HOME_DIR]="$HOME/.zinit"
    elif [[ -d ${ZDOTDIR:-$HOME}/.zinit ]]; then
        ZINIT[HOME_DIR]="${ZDOTDIR:-$HOME}/.zinit"
    elif [[ -d $HOME/.zplugin ]]; then
        ZINIT[HOME_DIR]="$HOME/.zplugin"
    elif [[ -d ${ZDOTDIR:-$HOME}/.zplugin ]]; then
        ZINIT[HOME_DIR]="${ZDOTDIR:-$HOME}/.zplugin"
    else
        ZINIT[HOME_DIR]="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit"
    fi
fi

if [[ -z ${ZINIT[LIST_COMMAND]} ]]; then
    if (( ${+commands[eza]} )); then
        ZINIT[LIST_COMMAND]='eza --color=always --tree --icons -L3'
    elif (( ${+commands[exa]} )); then
        ZINIT[LIST_COMMAND]='exa --color=always --tree --icons -L3'
    elif (( ${+commands[tree]} )); then
        ZINIT[LIST_COMMAND]='tree -L 3 -C --charset utf-8'
    else
        ZINIT[LIST_COMMAND]='ls --tree'
    fi
fi

ZINIT[ice-list]="\
\!bash|\!csh|\!ksh|\!sh|\
aliases|as|atclone|atdelete|atinit|atload|atpull|autoload|\
bash|binary|bindmap|blockf|bpick|build|\
cloneonly|cloneopts|cmake|compile|completions|configure|countdown|cp|csh|\
debug|depth|\
extract|\
from|git|\
has|\
id-as|if|install|is-snippet|\
ksh|\
light-mode|link|load|lucid|\
make|multisrc|mv|nocd|nocompile|nocompletions|notify|null|\
on-update-of|opts|\
pack|param|pick|proto|ps-on-unload|ps-on-update|pullopts|\
reset|reset-prompt|run-atpull|\
service|sh|silent|src|subscribe|subst|svn|\
teleid|trackbinds|trigger-load|\
unload|\
ver|verbose|\
wait|wrap"
ZINIT[nval-ice-list]="\
\!bash|\!csh|\!ksh|\!sh|\
aliases|\
bash|binary|blockf|\
cloneonly|cloneopts|cmake|configure|countdown|csh|\
debug|\
git|\
is-snippet|\
ksh|\
light-mode|lucid|\
make|\
nocd|nocompile|nocompletions|notify|null|\
pullopts|\
reset|run-atpull|\
sh|silent|\
trackbinds|\
verbose"
ZINIT[cmds]="\
add-fpath|\
bindkeys|\
cclear|cd|cdclear|cdisable|cdlist|cdreplay|cenable|changes|compile|compiled|compinit|completions|create|creinstall|csearch|cuninstall|\
delete|debug|\
edit|env-whitelist|\
fpath|\
glance|\
help|--help|-h|\
ice|\
light|load|\
man|module|\
plugins|\
recall|recently|report|run|\
self-update|snippet|snippets|srv|status|stress|\
times|\
uncompile|unload|update|\
version|\
zstatus"

# Can be customized.
: ${ZINIT[COMPLETIONS_DIR]:=${ZINIT[HOME_DIR]}/completions}
: ${ZINIT[MODULE_DIR]:=${ZINIT[HOME_DIR]}/module}
: ${ZINIT[PACKAGES_BRANCH]:=HEAD}
: ${ZINIT[PACKAGES_REPO]:=zdharma-continuum/zinit-packages}
: ${ZINIT[PLUGINS_DIR]:=${ZINIT[HOME_DIR]}/plugins}
: ${ZINIT[POLARIS_DIR]:=${ZINIT[HOME_DIR]}/polaris}
: ${ZINIT[SERVICES_DIR]:=${ZINIT[HOME_DIR]}/services}
: ${ZINIT[SNIPPETS_DIR]:=${ZINIT[HOME_DIR]}/snippets}
: ${ZINIT[ZPFX]:=${ZINIT[HOME_DIR]}/polaris}
typeset -g ZPFX
: ${ZPFX:=${ZINIT[ZPFX]}}
: ${ZINIT[ALIASES_OPT]::=${${options[aliases]:#off}:+1}}
: ${ZINIT[MAN_DIR]:=${ZPFX}/man}

ZINIT[PLUGINS_DIR]=${~ZINIT[PLUGINS_DIR]}   ZINIT[COMPLETIONS_DIR]=${~ZINIT[COMPLETIONS_DIR]}
ZINIT[SNIPPETS_DIR]=${~ZINIT[SNIPPETS_DIR]} ZINIT[SERVICES_DIR]=${~ZINIT[SERVICES_DIR]}

# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
  ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/zinit"
fi

export ZPFX=${~ZPFX} ZSH_CACHE_DIR="${ZSH_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/zinit}" \
    PMSPEC=0uUpiPsf
[[ -z ${path[(re)$ZPFX/bin]} ]] && [[ -d "$ZPFX/bin" ]] && path=( "$ZPFX/bin" "${path[@]}" )
[[ -z ${path[(re)$ZPFX/sbin]} ]] && [[ -d "$ZPFX/sbin" ]] && path=( "$ZPFX/sbin" "${path[@]}" )

hash -f
hash -d zinit=${ZINIT[HOME_DIR]}
hash -d plugins=${ZINIT[PLUGINS_DIR]}
hash -d zpfx=${ZINIT[HOME_DIR]}/polaris

# Add completions directory to fpath.
[[ -z ${fpath[(re)${ZINIT[COMPLETIONS_DIR]}]} ]] && fpath=( "${ZINIT[COMPLETIONS_DIR]}" "${fpath[@]}" )

[[ ! -d $ZSH_CACHE_DIR ]] && command mkdir -p "$ZSH_CACHE_DIR"
[[ -n ${ZINIT[ZCOMPDUMP_PATH]} ]] && ZINIT[ZCOMPDUMP_PATH]=${~ZINIT[ZCOMPDUMP_PATH]}

# Create "$ZSH_CACHE_DIR/completions" directory
[[ ! -d "$ZSH_CACHE_DIR/completions" ]] && command mkdir -p "$ZSH_CACHE_DIR/completions"
# Add "$ZSH_CACHE_DIR/completions" diretory to fpath
[[ -z ${fpath[(re)$ZSH_CACHE_DIR/completions]} ]] && fpath=( "$ZSH_CACHE_DIR/completions" "${fpath[@]}" )

ZINIT[UPAR]=";:^[[A;:^[OA;:\\e[A;:\\eOA;:${termcap[ku]/$'\e'/^\[};:${terminfo[kcuu1]/$'\e'/^\[};:"
ZINIT[DOWNAR]=";:^[[B;:^[OB;:\\e[B;:\\eOB;:${termcap[kd]/$'\e'/^\[};:${terminfo[kcud1]/$'\e'/^\[};:"
ZINIT[RIGHTAR]=";:^[[C;:^[OC;:\\e[C;:\\eOC;:${termcap[kr]/$'\e'/^\[};:${terminfo[kcuf1]/$'\e'/^\[};:"
ZINIT[LEFTAR]=";:^[[D;:^[OD;:\\e[D;:\\eOD;:${termcap[kl]/$'\e'/^\[};:${terminfo[kcub1]/$'\e'/^\[};:"

builtin autoload -Uz is-at-least
is-at-least 5.1 && ZINIT[NEW_AUTOLOAD]=1 || ZINIT[NEW_AUTOLOAD]=0
#is-at-least 5.4 && ZINIT[NEW_AUTOLOAD]=2

# Parameters [[[
# temporary substituting of functions
ZINIT[TMP_SUBST]=inactive ZINIT[DTRACE]=0 ZINIT[CUR_PLUGIN]=

# ice
declare -gA ZINIT_1MAP ZINIT_2MAP
ZINIT_1MAP=(
    OMZ:: https://github.com/ohmyzsh/ohmyzsh/trunk/
    OMZP:: https://github.com/ohmyzsh/ohmyzsh/trunk/plugins/
    OMZT:: https://github.com/ohmyzsh/ohmyzsh/trunk/themes/
    OMZL:: https://github.com/ohmyzsh/ohmyzsh/trunk/lib/
    PZT:: https://github.com/sorin-ionescu/prezto/trunk/
    PZTM:: https://github.com/sorin-ionescu/prezto/trunk/modules/
)
ZINIT_2MAP=(
    OMZ:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/
    OMZP:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/
    OMZT:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/themes/
    OMZL:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/lib/
    PZT:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/
    PZTM:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/modules/
)
# ]]]

# Init [[[
zmodload zsh/zutil || { builtin print -P "%F{196}zsh/zutil module is required, aborting Zinit set up.%f"; return 1; }
zmodload zsh/parameter || { builtin print -P "%F{196}zsh/parameter module is required, aborting Zinit set up.%f"; return 1; }
zmodload zsh/term{cap,info} 2>/dev/null
autoload -Uz colors && colors

if [[ -z $SOURCED && ( ${+terminfo} -eq 1 && -n ${terminfo[colors]} ) || ( ${+termcap} -eq 1 && -n ${termcap[Co]} ) ]]; then
  ZINIT+=(
    col-annex   $'\e[38;5;153m'         col-faint   $'\e[38;5;238m'         col-msg2    $'\e[38;5;172m'      col-quo     $'\e[1;38;5;33m'
    col-apo     $'\e[1;38;5;45m'        col-file    $'\e[3;38;5;117m'       col-msg3    $'\e[38;5;238m'      col-quos    $'\e[1;38;5;160m'
    col-aps     $'\e[38;5;117m'         col-flag    $'\e[1;3;38;5;79m'      col-nb      $'\e[22m'            col-rst     $'\e[0m'
    col-b       $'\e[1m'                col-func    $'\e[38;5;219m'         col-nit     $'\e[23m'            col-slight  $'\e[38;5;230m'
    col-b-lhi   $'\e[1m\e[38;5;75m'     col-glob    $'\e[38;5;227m'         col-nl      $'\n'                col-st      $'\e[9m'
    col-b-warn  $'\e[1;38;5;214m'       col-happy   $'\e[1m\e[38;5;82m'     col-note    $'\e[38;5;148m'      col-tab     $' \t '
    col-bapo    $'\e[1;38;5;220m'       col-hi      $'\e[1m\e[38;5;183m'    col-nst     $'\e[29m'            col-term    $'\e[38;5;185m'
    col-baps    $'\e[1;38;5;82m'        col-ice     $'\e[38;5;39m'          col-nu      $'\e[24m'            col-th-bar  $'\e[38;5;82m'
    col-bar     $'\e[38;5;82m'          col-id-as   $'\e[4;38;5;220m'       col-num     $'\e[3;38;5;155m'    col-time    $'\e[38;5;220m'
    col-bcmd    $'\e[38;5;220m'         col-info    $'\e[38;5;82m'          col-obj     $'\e[38;5;218m'      col-txt     $'\e[38;5;254m'
    col-bspc    $'\b'                   col-info2   $'\e[38;5;227m'         col-obj2    $'\e[38;5;118m'      col-u       $'\e[4m'
    col-cmd     $'\e[38;5;82m'          col-info3   $'\e[1m\e[38;5;227m'    col-ok      $'\e[38;5;220m'      col-u-warn  $'\e[4;38;5;214m'
    col-data    $'\e[38;5;82m'          col-it      $'\e[3m'                col-opt     $'\e[38;5;219m'      col-uname   $'\e[1;4m\e[35m'
    col-data2   $'\e[38;5;117m'         col-keyword $'\e[32m'               col-p       $'\e[38;5;81m'       col-uninst  $'\e[38;5;118m'
    col-dir     $'\e[3;38;5;153m'       col-lhi     $'\e[38;5;81m'          col-pkg     $'\e[1;3;38;5;27m'   col-url     $'\e[38;5;75m'
    col-ehi     $'\e[1m\e[38;5;210m'    col-meta    $'\e[38;5;57m'          col-pname   $'\e[1;4m\e[32m'     col-var     $'\e[38;5;81m'
    col-error   $'\e[1m\e[38;5;204m'    col-meta2   $'\e[38;5;147m'         col-pre     $'\e[38;5;135m'      col-version $'\e[3;38;5;87m'
    col-failure $'\e[38;5;204m'         col-msg     $'\e[0m'                col-profile $'\e[38;5;148m'      col-warn    $'\e[38;5;214m'

    col-dbg $'\e[2m\e[38;47;107m'"[debug]"$'\e[0m'
    col-e $'\e[1m\e[38;5;204m'"Error"$'\e[0m'":"
    col-i $'\e[1m\e[38;5;82m'"==>"$'\e[0m'
    col-m $'\e[38;5;4m'"==>"$'\e[0m'
    col-w $'\e[1m\e[38;5;214m'"Warning"$'\e[0m'":"

    col--…   "${${${(M)LANG:#*UTF-8*}:+⋯⋯}:-···}"    col-lr "${${${(M)LANG:#*UTF-8*}:+↔}:-"«-»"}"
    col-ndsh "${${${(M)LANG:#*UTF-8*}:+–}:-}"        col-…  "${${${(M)LANG:#*UTF-8*}:+…}:-...}"

    col-mdsh  $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+–}:--}"$'\e[0m'
    col-mmdsh $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+――}:--}"$'\e[0m'

    col-↔     ${${${(M)LANG:#*UTF-8*}:+$'\e[38;5;82m↔\e[0m'}:-$'\e[38;5;82m«-»\e[0m'}
  )
  if [[ ( ${+terminfo} -eq 1 && ${terminfo[colors]} -ge 256 ) || ( ${+termcap} -eq 1 && ${termcap[Co]} -ge 256 ) ]]; then
    ZINIT+=( col-pname $'\e[1;4m\e[38;5;39m' col-uname  $'\e[1;4m\e[38;5;207m' )
  fi
fi

# Hooks
typeset -gAH ZINIT_ZLE_HOOKS_LIST
ZINIT_ZLE_HOOKS_LIST=(
    zle-isearch-exit 1
    zle-isearch-update 1
    zle-line-pre-redraw 1
    zle-line-init 1
    zle-line-finish 1
    zle-history-line-set 1
    zle-keymap-select 1
    paste-insert 1
)
builtin setopt noaliases
# ]]]

#
# Temporary substituting of functions-related functions.
#

# FUNCTION: :zinit-reload-and-run [[[
# Marks given function ($3) for autoloading, and executes it triggering the
# load. $1 is the fpath dedicated to the function, $2 are autoload options.
# This function replaces "autoload -X", because using that on older Zsh
# versions causes problems with traps.
#
# So basically one creates function stub that calls :zinit-reload-and-run()
# instead of "autoload -X".
#
# Author: Bart Schaefer
#
# $1 - FPATH dedicated to function
# $2 - autoload options
# $3 - function name (one that needs autoloading)
:zinit-reload-and-run() {
    local fpath_prefix="$1" autoload_opts="$2" func="$3"
    shift 3

    # Unfunction caller function (its name is given).
    unfunction -- "$func"

    local -a ___fpath
    ___fpath=( ${fpath[@]} )
    local -a +h fpath
    # See #127.
    [[ $FPATH != *${${(@0)fpath_prefix}[1]}* ]] && \
        fpath=( ${(@0)fpath_prefix} ${___fpath[@]} )

    # After this the function exists again.
    builtin autoload ${(s: :)autoload_opts} -- "$func"

    # User wanted to call the function, not only load it.
    "$func" "$@"
} # ]]]
# FUNCTION: :zinit-tmp-subst-autoload [[[
# Hijack plugin's calls to the 'autoload' builtin.
#
# The hijacking gathers report data and runs custom `autoload' function, that doesn't need FPATH.
:zinit-tmp-subst-autoload() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt extendedglob warncreateglobal typesetsilent rcquotes
    local -a opts opts2 custom reply
    local func

    zparseopts -D -E -M -a opts ${(s::):-RTUXdkmrtWzwC} I+=opts2 S+:=custom

    builtin set -- ${@:#--}

    # Process the id-as''/teleid'' to get the plugin dir.
    .zinit-any-to-user-plugin $ZINIT[CUR_USPL2]
    [[ $reply[1] = % ]] && \
        local PLUGIN_DIR="$reply[2]" || \
        local PLUGIN_DIR="$ZINIT[PLUGINS_DIR]/${reply[1]:+$reply[1]---}${reply[2]//\//---}"


    # "fpath elements" ----  those elements that lie inside the plug directory.
    local -a fpath_elements
    fpath_elements=( ${fpath[(r)$PLUGIN_DIR/*]} )

    # Add a function subdirectory to items, if any (this action is
    # according to the Plug Standard version 1.07 and later).
    [[ -d $PLUGIN_DIR/functions ]] && fpath_elements+=( "$PLUGIN_DIR"/functions )

    if (( ${+opts[(r)-X]} )); then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: Failed autoload ${(j: :)opts[@]} $*"
        +zi-log -u2 "{error}builtin autoload required for {obj}${(j: :)opts[@]}{error} option(s)"
        return 1
    fi
    if (( ${+opts[(r)-w]} )); then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "-w-Autoload ${(j: :)opts[@]} ${(j: :)@}"
        fpath+=( $PLUGIN_DIR )
        builtin autoload ${opts[@]} "$@"
        return $?
    fi
    if [[ -n ${(M)@:#+X} ]]; then
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Autoload +X ${opts:+${(j: :)opts[@]} }${(j: :)${@:#+X}}"
        local +h FPATH=$PLUGINS_DIR${fpath_elements:+:${(j.:.)fpath_elements[@]}}:$FPATH
        local +h -a fpath
        fpath=( $PLUGIN_DIR $fpath_elements $fpath )
        builtin autoload +X ${opts[@]} "${@:#+X}"
        return $?
    fi

    for func; do
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Autoload $func${opts:+ with options ${(j: :)opts[@]}}"
    done

    integer count retval
    for func; do
        # Real autoload doesn't touch function if it already exists.
        # Author of the idea of FPATH-clean autoloading: Bart Schaefer.
        if (( ${+functions[$func]} != 1 )) {
            builtin setopt noaliases
            if [[ $func == /* ]] && is-at-least 5.4; then
                builtin autoload ${opts[@]} $func
                return $?
            elif [[ $func == /* ]]; then
                if [[ $ZINIT[MUTE_WARNINGS] != (1|true|on|yes) && \
                        -z $ZINIT[WARN_SHOWN_FOR_$ZINIT[CUR_USPL2]] ]]; then
                    +zi-log "{u-warn}Warning{b-warn}: {rst}the plugin {pid}$ZINIT[CUR_USPL2]" \
                        "{rst}is using autoload functions specified by their absolute path," \
                        "which is not supported by this Zsh version ({↔} {version}$ZSH_VERSION{rst}," \
                        "required is Zsh >= {version}5.4{rst})." \
                        "{nl}A fallback mechanism has been applied, which works well only" \
                        "for functions in the plugin {u}{slight}main{rst} directory." \
                        "{nl}(To mute this message, set" \
                        "{var}\$ZINIT[MUTE_WARNINGS]{rst} to a truth value.)"
                    ZINIT[WARN_SHOWN_FOR_$ZINIT[CUR_USPL2]]=1
                fi

                # Workaround
                func=$func:t
            fi
            if [[ ${ZINIT[NEW_AUTOLOAD]} = 2 ]]; then
                builtin autoload ${opts[@]} "$PLUGIN_DIR/$func"
                retval=$?
            elif [[ ${ZINIT[NEW_AUTOLOAD]} = 1 ]]; then
                if (( ${+opts[(r)-C]} )) {
                    local pth nl=$'\n' sel=""
                    for pth ( $PLUGIN_DIR $fpath_elements $fpath ) {
                        [[ -f $pth/$func ]] && { sel=$pth; break; }
                    }
                    if [[ -z $sel ]] {
                        +zi-log '{u-warn}zinit{b-warn}:{error} Couldn''t find autoload function{ehi}:' \
                            "{apo}\`{file}${func}{apo}\`{error} anywhere in {var}\$fpath{error}."
                            retval=1
                    } else {
                        eval "function ${(q)${custom[++count*2]}:-$func} {
                            local body=\"\$(<${(qqq)sel}/${(qqq)func})\" body2
                            () { setopt localoptions extendedglob
                                 body2=\"\${body##[[:space:]]#${func}[[:blank:]]#\(\)[[:space:]]#\{}\"
                                 [[ \$body2 != \$body ]] && \
                                    body2=\"\${body2%\}[[:space:]]#([$nl]#([[:blank:]]#\#[^$nl]#((#e)|[$nl]))#)#}\"
                            }

                            functions[${${(q)custom[count*2]}:-$func}]=\"\$body2\"
                            ${(q)${custom[count*2]}:-$func} \"\$@\"
                        }"
                        retval=$?
                    }
                } else {
                    functions[$func]="
                        local -a fpath
                        fpath=( ${(qqq)PLUGIN_DIR} ${(qqq@)fpath_elements} ${(qqq@)fpath} )
                        builtin autoload -X ${(j: :)${(q-)opts[@]}}
                    "
                    retval=$?
                }
            else
                eval "function ${(q)func} {
                    :zinit-reload-and-run ${(qqq)PLUGIN_DIR}"$'\0'"${(pj,\0,)${(qqq)fpath_elements[@]}} ${(qq)opts[*]} ${(q)func} "'"$@"
                }'
                retval=$?
            fi
            (( ZINIT[ALIASES_OPT] )) && builtin setopt aliases
        }
        if (( ${+opts2[(r)-I]} )) {
            ${custom[count*2]:-$func}
            retval=$?
        }
    done

    return $retval
} # ]]]
# FUNCTION: :zinit-tmp-subst-bindkey [[[
# Function defined to hijack plugin's calls to the `bindkey' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-bindkey() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
    builtin setopt extendedglob warncreateglobal typesetsilent noshortloops

    is-at-least 5.3 && \
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Bindkey ${(j: :)${(q+)@}}" || \
        .zinit-add-report "${ZINIT[CUR_USPL2]}" "Bindkey ${(j: :)${(q)@}}"

    # Remember to perform the actual bindkey call.
    typeset -a pos
    pos=( "$@" )

    # Check if we have regular bindkey call, i.e.
    # with no options or with -s, plus possible -M
    # option.
    local -A opts
    zparseopts -A opts -D ${(s::):-lLdDAmrsevaR} M: N:

    if (( ${#opts} == 0 ||
        ( ${#opts} == 1 && ${+opts[-M]} ) ||
        ( ${#opts} == 1 && ${+opts[-R]} ) ||
        ( ${#opts} == 1 && ${+opts[-s]} ) ||
        ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-s]} ) ||
        ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-R]} )
    )); then
        local string="${(q)1}" widget="${(q)2}"
        local quoted

        if [[ -n ${ICE[bindmap]} && ${ZINIT_CUR_BIND_MAP[empty]} -eq 1 ]]; then
            local -a pairs
            pairs=( "${(@s,;,)ICE[bindmap]}" )
            if [[ -n ${(M)pairs:#*\\(#e)} ]] {
                local prev
                pairs=( ${pairs[@]//(#b)((*)\\(#e)|(*))/${match[3]:+${prev:+$prev\;}}${match[3]}${${prev::=${match[2]:+${prev:+$prev\;}}${match[2]}}:+}} )
            }
            pairs=( "${(@)${(@)${(@s:->:)pairs}##[[:space:]]##}%%[[:space:]]##}" )
            ZINIT_CUR_BIND_MAP=( empty 0 )
            (( ${#pairs} > 1 && ${#pairs[@]} % 2 == 0 )) && ZINIT_CUR_BIND_MAP+=( "${pairs[@]}" )
        fi

        local bmap_val="${ZINIT_CUR_BIND_MAP[${1}]}"
        if (( !ZINIT_CUR_BIND_MAP[empty] )) {
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[${(qqq)1}]}"
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[${(qqq)${(Q)1}}]}"
            [[ -z $bmap_val ]] && { bmap_val="${ZINIT_CUR_BIND_MAP[!${(qqq)1}]}"; integer val=1; }
            [[ -z $bmap_val ]] && bmap_val="${ZINIT_CUR_BIND_MAP[!${(qqq)${(Q)1}}]}"
        }
        if [[ -n $bmap_val ]]; then
            string="${(q)bmap_val}"
            if (( val )) {
                [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
            } else {
                [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
            }
            .zinit-add-report "${ZINIT[CUR_USPL2]}" ":::Bindkey: combination <$1> changed to <$bmap_val>${${(M)bmap_val:#hold}:+, i.e. ${ZINIT[col-error]}unmapped${ZINIT[col-rst]}}"
            ((1))
        elif [[ ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[UPAR]}} && -n ${${ZINIT[UPAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[DOWNAR]}} && -n ${${ZINIT[DOWNAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[RIGHTAR]}} && -n ${${ZINIT[RIGHTAR]}[(r);:${(q)1};:]} ) || \
                ( -n ${bmap_val::=${ZINIT_CUR_BIND_MAP[LEFTAR]}} && -n ${${ZINIT[LEFTAR]}[(r);:${(q)1};:]} )
        ]]; then
            string="${(q)bmap_val}"
            if (( val )) {
                [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
            } else {
                [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
            }
            .zinit-add-report "${ZINIT[CUR_USPL2]}" ":::Bindkey: combination <$1> recognized as cursor-key and changed to <${bmap_val}>${${(M)bmap_val:#hold}:+, i.e. ${ZINIT[col-error]}unmapped${ZINIT[col-rst]}}"
        fi
        [[ $bmap_val = hold ]] && return 0

        local prev="${(q)${(s: :)$(builtin bindkey ${(Q)string})}[-1]#undefined-key}"

        # "-M map" given?
        if (( ${+opts[-M]} )); then
            local Mopt=-M
            local Marg="${opts[-M]}"

            Mopt="${(q)Mopt}"
            Marg="${(q)Marg}"

            quoted="$string $widget $prev $Mopt $Marg"
        else
            quoted="$string $widget $prev"
        fi

        # -R given?
        if (( ${+opts[-R]} )); then
            local Ropt=-R
            Ropt="${(q)Ropt}"

            if (( ${+opts[-M]} )); then
                quoted="$quoted $Ropt"
            else
                # Two empty fields for non-existent -M arg.
                local space=_
                space="${(q)space}"
                quoted="$quoted $space $space $Ropt"
            fi
        fi

        quoted="${(q)quoted}"

        # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "
    else
        # bindkey -A newkeymap main?
        # Negative indices for KSH_ARRAYS immunity.
        if [[ ${#opts} -eq 1 && ${+opts[-A]} = 1 && ${#pos} = 3 && ${pos[-1]} = main && ${pos[-2]} != -A ]]; then
            # Save a copy of main keymap.
            (( ZINIT[BINDKEY_MAIN_IDX] = ${ZINIT[BINDKEY_MAIN_IDX]:-0} + 1 ))
            local pname="${ZINIT[CUR_PLUGIN]:-_dtrace}"
            local name="${(q)pname}-main-${ZINIT[BINDKEY_MAIN_IDX]}"
            builtin bindkey -N "$name" main

            # Remember occurence of main keymap substitution, to revert on unload.
            local keys=_ widget=_ prev= optA=-A mapname="${name}" optR=_
            local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optA} ${(q)mapname} ${(q)optR}"
            quoted="${(q)quoted}"

            # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
            [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
            [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "

            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: keymap \`main' copied to \`${name}' because of \`${pos[-2]}' substitution"
        # bindkey -N newkeymap [other].
        elif [[ ${#opts} -eq 1 && ${+opts[-N]} = 1 ]]; then
            local Nopt=-N
            local Narg="${opts[-N]}"

            local keys=_ widget=_ prev= optN=-N mapname="${Narg}" optR=_
            local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optN} ${(q)mapname} ${(q)optR}"
            quoted="${(q)quoted}"

            # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
            [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[BINDKEYS__${ZINIT[CUR_USPL2]}]+="$quoted "
            [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[BINDKEYS___dtrace/_dtrace]+="$quoted "
        else
            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: last bindkey used non-typical options: ${(kv)opts[*]}"
        fi
    fi

    # Actual bindkey.
    builtin bindkey "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-zstyle [[[
# Function defined to hijack plugin's calls to the `zstyle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-zstyle() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob nowarncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Zstyle $*"

    # Remember in order to perform the actual zstyle call.
    typeset -a pos
    pos=( "$@" )

    # Check if we have regular zstyle call, i.e.
    # with no options or with -e.
    local -a opts
    zparseopts -a opts -D ${(s::):-eLdgabsTtm}

    if [[ ${#opts} -eq 0 || ( ${#opts} -eq 1 && ${+opts[(r)-e]} = 1 ) ]]; then
        # Have to quote $1, then $2, then concatenate them, then quote them again.
        local pattern="${(q)1}" style="${(q)2}"
        local ps="$pattern $style"
        ps="${(q)ps}"

        # Remember the zstyle, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[ZSTYLES__${ZINIT[CUR_USPL2]}]+="$ps "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[ZSTYLES___dtrace/_dtrace]+=$ps
    else
        if [[ ! ${#opts[@]} = 1 && ( ${+opts[(r)-s]} = 1 || ${+opts[(r)-b]} = 1 || ${+opts[(r)-a]} = 1 ||
              ${+opts[(r)-t]} = 1 || ${+opts[(r)-T]} = 1 || ${+opts[(r)-m]} = 1 )
        ]]; then
            .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: last zstyle used non-typical options: ${opts[*]}"
        fi
    fi

    # Actual zstyle.
    builtin zstyle "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-alias [[[
# Function defined to hijack plugin's calls to the `alias' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-alias() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Alias $*"

    # Remember to perform the actual alias call.
    typeset -a pos
    pos=( "$@" )

    local -a opts
    zparseopts -a opts -D ${(s::):-gs}

    local a quoted tmp
    for a in "$@"; do
        local aname="${a%%[=]*}"
        local avalue="${a#*=}"

        # Check if alias is to be redefined.
        (( ${+aliases[$aname]} )) && .zinit-add-report "${ZINIT[CUR_USPL2]}" "Warning: redefining alias \`${aname}', previous value: ${aliases[$aname]}"

        local bname=${(q)aliases[$aname]}
        aname="${(q)aname}"

        if (( ${+opts[(r)-s]} )); then
            tmp=-s
            tmp="${(q)tmp}"
            quoted="$aname $bname $tmp"
        elif (( ${+opts[(r)-g]} )); then
            tmp=-g
            tmp="${(q)tmp}"
            quoted="$aname $bname $tmp"
        else
            quoted="$aname $bname"
        fi

        quoted="${(q)quoted}"

        # Remember the alias, only when load is in progress (it can be dstart that leads execution here).
        [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[ALIASES__${ZINIT[CUR_USPL2]}]+="$quoted "
        # Remember for dtrace.
        [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[ALIASES___dtrace/_dtrace]+="$quoted "
    done

    # Actual alias.
    builtin alias "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-zle [[[.
# Function defined to hijack plugin's calls to the `zle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zinit-tmp-subst-zle() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Zle $*"

    # Remember to perform the actual zle call.
    typeset -a pos
    pos=( "$@" )

    builtin set -- "${@:#--}"

    # Try to catch game-changing "-N".
    if [[ ( $1 = -N && ( $# = 2 || $# = 3 ) ) || ( $1 = -C && $# = 4 ) ]]; then
            # Hooks.
            if [[ ${ZINIT_ZLE_HOOKS_LIST[$2]} = 1 ]]; then
                local quoted="$2"
                quoted="${(q)quoted}"
                # Remember only when load is in progress (it can be dstart that leads execution here).
                [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_DELETE__${ZINIT[CUR_USPL2]}]+="$quoted "
                # Remember for dtrace.
                [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
            # These will be saved and restored.
            elif (( ${+widgets[$2]} )); then
                # Have to remember original widget "$2" and
                # the copy that it's going to be done.
                local widname="$2" targetfun="${${${(M)1:#-C}:+$4}:-$3}"
                local completion_widget="${${(M)1:#-C}:+$3}"
                local saved_widcontents="${widgets[$widname]}"

                widname="${(q)widname}"
                completion_widget="${(q)completion_widget}"
                targetfun="${(q)targetfun}"
                saved_widcontents="${(q)saved_widcontents}"
                local quoted="$1 $widname $completion_widget $targetfun $saved_widcontents"
                quoted="${(q)quoted}"
                # Remember only when load is in progress (it can be dstart that leads execution here).
                [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_SAVED__${ZINIT[CUR_USPL2]}]+="$quoted "
                # Remember for dtrace.
                [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_SAVED___dtrace/_dtrace]+="$quoted "
             # These will be deleted.
             else
                 .zinit-add-report "${ZINIT[CUR_USPL2]}" "Note: a new widget created via zle -N: \`$2'"
                 local quoted="$2"
                 quoted="${(q)quoted}"
                 # Remember only when load is in progress (it can be dstart that leads execution here).
                 [[ -n ${ZINIT[CUR_USPL2]} ]] && ZINIT[WIDGETS_DELETE__${ZINIT[CUR_USPL2]}]+="$quoted "
                 # Remember for dtrace.
                 [[ ${ZINIT[DTRACE]} = 1 ]] && ZINIT[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
             fi
    fi

    # Actual zle.
    builtin zle "${pos[@]}"
    return $? # testable
} # ]]]
# FUNCTION: :zinit-tmp-subst-compdef [[[
# Function defined to hijack plugin's calls to the `compdef' function.
# The hijacking is not only for reporting, but also to save compdef
# calls so that `compinit' can be called after loading plugins.
:zinit-tmp-subst-compdef() {
    builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
        typesetsilent noshortloops unset
    .zinit-add-report "${ZINIT[CUR_USPL2]}" "Saving \`compdef $*' for replay"
    ZINIT_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" )

    return 0 # testable
} # ]]]
# FUNCTION: .zinit-tmp-subst-on [[[
# Turn on temporary substituting of functions of builtins and functions according to passed
# mode ("load", "light", "light-b" or "compdef"). The temporary substituting of functions is
# to gather report data, and to hijack 'autoload', 'bindkey' and 'compdef' calls.
.zinit-tmp-subst-on() {
    local mode="$1"

    # Enable temporary substituting of functions only once.
    #
    # One could expect possibility of widening of temporary substituting of functions, however
    # such sequence doesn't exist, e.g. "light" then "load"/"dtrace", "compdef" then "load"/
    # "dtrace", "light" then "compdef", "compdef" then "light".
    #
    # It is always "dtrace" then "load" (i.e. dtrace then load) "dtrace" then "light" (i.e.:
    # dtrace then light load) "dtrace" then "compdef" (i.e.: dtrace then snippet).
    [[ ${ZINIT[TMP_SUBST]} != inactive ]] && builtin return 0

    ZINIT[TMP_SUBST]="$mode"

    # The point about backuping is: does the key exist in functions array.
    # If it does exist, then it will also exist as ZINIT[bkp-*].

    # Defensive code, shouldn't be needed.
    builtin unset "ZINIT[bkp-autoload]" "ZINIT[bkp-compdef]"  # 0, E.

    if [[ $mode != compdef ]]; then
        # 0. Used, but not in temporary restoration, which doesn't happen for autoload.
        (( ${+functions[autoload]} )) && ZINIT[bkp-autoload]="${functions[autoload]}"
        functions[autoload]=':zinit-tmp-subst-autoload "$@";'
    fi

    # E. Always shade compdef.
    (( ${+functions[compdef]} )) && ZINIT[bkp-compdef]="${functions[compdef]}"
    functions[compdef]=':zinit-tmp-subst-compdef "$@";'

    # Temporarily replace `source' if subst'' given.
    if [[ -n ${ICE[subst]} ]] {
        (( ${+functions[source]} )) && ZINIT[bkp-source]="${functions[source]}"
        (( ${+functions[.]} )) && ZINIT[bkp-.]="${functions[.]}"
        (( ${+functions[.zinit-service]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-additional.zsh"
        functions[source]=':zinit-tmp-subst-source "$@";'
        functions[.]=':zinit-tmp-subst-source "$@";'
    }

    # Light and compdef temporary substituting of functions stops here. Dtrace and load go on.
    [[ ( $mode = light && ${+ICE[trackbinds]} -eq 0 ) || $mode = compdef ]] && return 0
... truncated; 2,551 more lines

[0x09c] GRAMMAR & SYNTAX — CANONICAL TABLES

Every reserved keyword, builtin, setopt option, special variable, parameter flag, glob qualifier, operator, history expansion, and word modifier recognized by zshrs. Sourced directly from upstream zsh C tables (Src/hashtable.c::reswds[], Src/builtin.c::builtins[], Src/Modules/*.c, Src/options.c::optns[], Src/params.c::special_params[]) plus the zshrs extension builtins in daemon/builtins.rs + src/extensions/. Single source of truth lives at data/grammar/canonical.json; regenerate this section via python3 scripts/gen_grammar_docs.py.

50
Keywords
157
Builtins
196
Options
88
Special vars
38
Param flags
44
Glob quals
55
Operators
10
History exp.
16
Modifiers

Generated 2026-05-31 from data/grammar/canonical.json.

Reserved keywords (50)

Source: src/zsh/Src/hashtable.c::reswds[] + zshrs lexer extensions.

Control flow (20)

[[ ]] always case do done elif else end esac fi for foreach if in repeat select then until while

Declaration (10)

declare export float integer let local readonly set shift typeset

Function (1)

function

Grouping (2)

{ }

I/O / source (5)

. eval exec source trap

Loop control (5)

break continue exit logout return

Modifier (precommand) (6)

builtin command coproc nocorrect noglob time

Operator-like (1)

!

Builtins (157)

Every command implemented inside the shell — no fork/exec required.

POSIX / zsh core (74)

Source: src/zsh/Src/builtin.c::builtins[].

. : [ alias autoload bg break bye cd chdir continue declare dirs disable disown echo emulate enable eval exit export false fc fg float functions getln getopts hash hashinfo history integer jobs kill let local logout mem patdebug popd print printf pushd pushln pwd r read readonly rehash return set setopt shift source suspend test times trap true ttyctl type typeset umask unalias unfunction unhash unset unsetopt wait whence where which zcompile zmodload

zsh modules (59)

Source: src/zsh/Src/Modules/*.c (curses, datetime, pcre, files, stat, terminfo, zftp, zselect, zsystem, zutil, …).

cap chgrp chmod chown clone echotc echoti example getcap ln local log mkdir mv nameref pcre_compile pcre_match pcre_study private rm rmdir setcap stat strftime sync syserror sysopen sysread sysseek syswrite zcurses zdelattr zf_chgrp zf_chmod zf_chown zf_ln zf_mkdir zf_mv zf_rm zf_rmdir zf_sync zformat zftp zgdbmpath zgetattr zlistattr zparseopts zprof zpty zregexparse zselect zsetattr zsocket zstat zstyle zsystem ztcp ztie zuntie

zshrs extensions (24)

Source: daemon/builtins.rs + src/extensions/ext_builtins.rs.

zask zcache zcompdump zcomplete zd zhistory zid zjob zlock zlog zls znotify zping zpublish zsend zsource zsubscribe zsuggest zsync ztag zunsubscribe zuntag zwc zwhere

setopt options (196)

Source: src/zsh/Src/options.c::optns[]. All upstream zsh options recognized by name; use setopt / unsetopt to toggle, or NO_ prefix (e.g. NO_GLOB).

ALIASES ALIASFUNCDEF ALLEXPORT ALWAYSLASTPROMPT ALWAYSTOEND APPENDCREATE APPENDHISTORY AUTOCD AUTOCONTINUE AUTOLIST AUTOMENU AUTONAMEDIRS AUTOPARAMKEYS AUTOPARAMSLASH AUTOPUSHD AUTOREMOVESLASH AUTORESUME BADPATTERN BANGHIST BAREGLOBQUAL BASHAUTOLIST BASHREMATCH BEEP BGNICE BRACECCL BRACEEXPAND BSDECHO CASEGLOB CASEMATCH CASEPATHS CBASES CDABLEVARS CDSILENT CHASEDOTS CHASELINKS CHECKJOBS CHECKRUNNINGJOBS CLOBBER CLOBBEREMPTY COMBININGCHARS COMPLETEALIASES COMPLETEINWORD CONTINUEONERROR CORRECT CORRECTALL CPRECEDENCES CSHJUNKIEHISTORY CSHJUNKIELOOPS CSHJUNKIEQUOTES CSHNULLCMD CSHNULLGLOB DEBUGBEFORECMD DOTGLOB DVORAK EMACS EQUALS ERREXIT ERRRETURN EVALLINENO EXEC EXTENDEDGLOB EXTENDEDHISTORY FLOWCONTROL FORCEFLOAT FUNCTIONARGZERO GLOB GLOBALEXPORT GLOBALRCS GLOBASSIGN GLOBCOMPLETE GLOBDOTS GLOBSTARSHORT GLOBSUBST HASHALL HASHCMDS HASHDIRS HASHEXECUTABLESONLY HASHLISTALL HISTALLOWCLOBBER HISTAPPEND HISTBEEP HISTEXPAND HISTEXPIREDUPSFIRST HISTFCNTLLOCK HISTFINDNODUPS HISTIGNOREALLDUPS HISTIGNOREDUPS HISTIGNORESPACE HISTLEXWORDS HISTNOFUNCTIONS HISTNOSTORE HISTREDUCEBLANKS HISTSAVEBYCOPY HISTSAVENODUPS HISTSUBSTPATTERN HISTVERIFY HUP IGNOREBRACES IGNORECLOSEBRACES IGNOREEOF INCAPPENDHISTORY INCAPPENDHISTORYTIME INTERACTIVE INTERACTIVECOMMENTS KSHARRAYS KSHAUTOLOAD KSHGLOB KSHOPTIONPRINT KSHTYPESET KSHZEROSUBSCRIPT LISTAMBIGUOUS LISTBEEP LISTPACKED LISTROWSFIRST LISTTYPES LOCALLOOPS LOCALOPTIONS LOCALPATTERNS LOCALTRAPS LOG LOGIN LONGLISTJOBS MAGICEQUALSUBST MAILWARN MAILWARNING MARKDIRS MENUCOMPLETE MONITOR MULTIBYTE MULTIFUNCDEF MULTIOS NOMATCH NOTIFY NULLGLOB NUMERICGLOBSORT OCTALZEROES ONECMD OVERSTRIKE PATHDIRS PATHSCRIPT PHYSICAL PIPEFAIL POSIXALIASES POSIXARGZERO POSIXBUILTINS POSIXCD POSIXIDENTIFIERS POSIXJOBS POSIXSTRINGS POSIXTRAPS PRINTEIGHTBIT PRINTEXITVALUE PRIVILEGED PROMPTBANG PROMPTCR PROMPTPERCENT PROMPTSP PROMPTSUBST PROMPTVARS PUSHDIGNOREDUPS PUSHDMINUS PUSHDSILENT PUSHDTOHOME RCEXPANDPARAM RCQUOTES RCS RECEXACT REMATCHPCRE RMSTARSILENT RMSTARWAIT SHAREHISTORY SHFILEEXPANSION SHGLOB SHINSTDIN SHNULLCMD SHOPTIONLETTERS SHORTLOOPS SHORTREPEAT SHWORDSPLIT SINGLECOMMAND SINGLELINEZLE SOURCETRACE STDIN SUNKEYBOARDHACK TRACKALL TRANSIENTRPROMPT TRAPSASYNC TYPESETSILENT TYPESETTOUNSET UNSET VERBOSE VI WARNCREATEGLOBAL WARNNESTEDVAR XTRACE ZLE

Special variables (88)

Source: src/zsh/Src/params.c::special_params[]. Includes scalar ($?, $RANDOM) and array forms ($path, $pipestatus); upper-case and lower-case names are linked pairs where applicable.

$! $# $$ $* $- $0 $? $@ $ARGC $CDPATH $COLUMNS $EGID $ERRNO $EUID $FIGNORE $FPATH $FUNCNEST $GID $HISTCHARS $HISTCMD $HISTSIZE $HOME $IFS $KEYBOARD_HACK $LANG $LC_ALL $LC_COLLATE $LC_CTYPE $LC_MESSAGES $LC_NUMERIC $LC_TIME $LINENO $LINES $MAILPATH $MANPATH $MODULE_PATH $NULLCMD $OPTARG $OPTIND $PATH $POSTEDIT $PPID $PROMPT $PROMPT2 $PROMPT3 $PROMPT4 $PS1 $PS2 $PS3 $PS4 $PSVAR $RANDOM $READNULLCMD $RPROMPT $RPROMPT2 $RPS1 $RPS2 $SAVEHIST $SECONDS $SHLVL $SPROMPT $TERM $TERMINFO $TERMINFO_DIRS $TRY_BLOCK_ERROR $TRY_BLOCK_INTERRUPT $TTYIDLE $UID $USERNAME $WORDCHARS $ZLE_RPROMPT_INDENT $ZSH_EVAL_CONTEXT $ZSH_SUBSHELL $_ $argv $cdpath $fignore $fpath $histchars $mailpath $manpath $module_path $path $pipestatus $prompt $psvar $status $zsh_eval_context

Parameter expansion flags (38)

Single-letter modifiers inside ${(X)var}. Composable: ${(jL)arr} = join lowercase.

FlagMeaning
${(@)var}array-context retain $@ semantics; quoting-preserving even in scalar context
${(A)var}create as an array
${(a)var}sort by array index
${(c)var}count words in a parameter (e.g., scalar split count)
${(C)var}capitalize words
${(D)var}treat as DIRECTORY name (apply directory substitution like ~/...)
${(e)var}perform parameter expansion / arithmetic / etc. on the result
${(f)var}split result at newlines
${(F)var}join array elements with newlines
${(g)var}process escape sequences like print does (g:o: process octals, g:c: process \c)
${(i)var}case-insensitive sort
${(j)var}join array with separator: ${(j:sep:)arr}
${(k)var}for assoc arrays: keys ${(k)hash}
${(K)var}subscript flags: use keys
${(L)var}lowercase
${(M)var}match: use longest match (also for case-insensitivity in sort)
${(n)var}numeric sort
${(o)var}sort ascending
${(O)var}sort descending
${(p)var}interpret embedded escape sequences in j/s separator
${(P)var}treat value as parameter name → indirect (P)
${(q)var}quote the result (q-/q+/qq/qqq variants for shell-quote levels)
${(Q)var}remove quoting
${(r)var}right-justify within field width: ${(r:N::pad:)var}
${(l)var}left-justify within field width: ${(l:N::pad:)var}
${(s)var}split at separator: ${(s:sep:)var}
${(S)var}subscript: search subscript ranges
${(t)var}test parameter type
${(u)var}unique (dedupe array)
${(U)var}uppercase
${(v)var}for assoc arrays: values ${(v)hash}
${(V)var}make invisible / control chars visible
${(w)var}split into words
${(W)var}split into words (alternate)
${(z)var}split as the shell would (z-tokens)
${(#)var}expand result as arithmetic; numeric value
${(%)var}expand prompt percent escapes in result
${(~)var}treat values as patterns (e.g., for /pat/repl)

Glob qualifiers (44)

Modifiers inside *(X). Composable; use ^ to negate the group, , to OR-combine groups.

QualMeaning
*(/)directories only
*(.)regular files only
*(@)symbolic links only
*(=)sockets only
*(p)named pipes (FIFOs) only
*(*)executable plain files only
*(%)device special files only
*(%b)block special files
*(%c)character special files
*(r)owner-readable
*(w)owner-writable
*(x)owner-executable
*(A)group-readable
*(I)group-writable
*(E)group-executable
*(R)world-readable
*(W)world-writable
*(X)world-executable
*(s)setuid (S_ISUID)
*(S)setgid (S_ISGID)
*(t)sticky bit
*(d N)device number N
*(l[+-=]N)exactly / less-than / greater-than N hard links
*(U)owned by EUID
*(G)owned by EGID
*(u N)owned by uid N
*(g N)group gid N
*(f spec)permission mask: f:o+w: e.g.
*(L [+-=] N)size: blocks / k / m / p suffix (Lk / Lm / Lp)
*(a [Mwhms] [+-=] N)access time
*(m [Mwhms] [+-=] N)modify time
*(c [Mwhms] [+-=] N)ctime
*(o [name|size|links|mtime|atime|ctime])sort ascending
*(O [name|size|links|mtime|atime|ctime])sort descending
*([N,M])select range of matches
*(e:str:)external test: each match passed to expression
*(+func)external test: each match passed to function
*(N)nullglob: silently drop unmatched pattern
*(D)include dotfiles
*(Y N)limit to N results
*(M)include directory names as if trailing slash
*(:mod)apply history modifier (e.g., :t :h :r :e)
*(^)negate the qualifier list
*(,)OR-combine qualifier groups

Operators / redirections / substitution forms (55)

Lexer-recognized tokens. Grouped by kind: pipeline / list / case / redirect / procsub / subst / arith / cond / assign / compare / glob / tilde / brace / expansion / string / extension.

SymbolKindMeaning
|pipelinePipeline. stdout of LHS → stdin of RHS.
|&pipelinePipeline with stderr merged (= |2>&1).
&&listLogical AND: run RHS only if LHS exit==0.
||listLogical OR: run RHS only if LHS exit!=0.
;listSequence: run RHS after LHS regardless of status.
&listBackground: run LHS async; sets $!.
;;caseEnd case arm.
;;&caseFall through and test next case pattern.
;|caseFall through without test.
!negNegate exit status (reserved word).
>redirectStdout redirect (overwrite).
>>redirectStdout append.
<redirectStdin redirect.
<<redirectHeredoc; body terminated by marker.
<<-redirectHeredoc, strip leading tabs from body.
<<<redirectHere-string; literal text as stdin.
>|redirectStdout force-overwrite (bypass NO_CLOBBER).
>!redirectSame as >|; force-overwrite.
&>redirectRedirect both stdout and stderr (bash-compat).
&>>redirectAppend both stdout and stderr.
2>&1redirectDuplicate fd2 to fd1 (stderr → stdout).
>&-redirectClose fd.
<>redirectOpen for read+write.
<(procsubProcess substitution: <(cmd) is a path readable from cmd's stdout.
>(procsubProcess substitution: >(cmd) is a path writable into cmd's stdin.
=(procsubZsh-only =(cmd): tempfile capture.
$(substCommand substitution: $(cmd) captures cmd's stdout.
${substParameter expansion: ${var}.
$((substArithmetic expansion: $((expr)).
((arithArithmetic command. ((expr)) exits 0 iff expr != 0.
))arithClose arithmetic command.
[[condOpen conditional command: [[ expr ]].
]]condClose conditional command.
=assignAssignment. Also: equality in [[ ]].
+=assignAppend assignment (scalar concat / array push).
-=assignNumeric subtract-assign (in (( ))).
:=assign${var:=default}: assign default if unset/empty.
?=assign(arith) ternary.
==compareEquality in (( )) / [[ ]].
!=compareInequality.
=~compareRegex match in [[ ]] (POSIX ERE / PCRE depending on opts).
*globGlob: match any sequence (including empty).
**globRecursive glob (matches dir/subdir/.../ levels).
?globGlob: match one character.
~tildeTilde expansion: ~ → $HOME, ~user, ~+ / ~- / ~N for dirstack.
{a,b,c}braceBrace expansion: comma-separated list.
{1..10}braceBrace expansion: numeric range.
{a..z}braceBrace expansion: character range.
${~var}expansionTreat result of var as pattern.
${^var}expansionArray element rcexpansion.
${=var}expansionWord-split on IFS.
$'…'stringANSI-C quoted string: \n \t \xNN etc.
$"…"stringLocale-translated string.
`…`substBacktick command substitution (legacy form of $()).
@{}extensionZshrs @-prefix: dispatch to stryke embedded scripting.

History expansions (10)

Recall previous commands / words. Lexer-stage expansion before parsing.

FormMeaning
!!previous command
!Ncommand N in history
!-Ncommand N back
!?strmost recent containing str
!strmost recent starting with str
!$last word of previous command
!^first arg of previous command
!*all args of previous command
!:NNth word of previous command
^old^newquick substitute in previous command

Word modifiers (16)

Trailing :X modifiers applied to history words, filename expansions, and parameter results.

ModifierMeaning
:hhead: dirname of path
:ttail: basename of path
:rroot: strip extension
:eextension: keep only extension
:llowercase
:uuppercase
:qquote for shell re-input
:Qremove quoting
:s/old/new/substitute first match
:gs/old/new/global substitute
:aabsolutize (resolve relative path)
:Aabsolutize and resolve symlinks
:Pphysical resolved path
:xsplit into words on whitespace
:wselect words
:Ffollow symlinks (in conjunction with above)

[0xFF] THE PHILOSOPHY

Shells haven't fundamentally improved since the 1990s. bash is a GNU rewrite of the Bourne shell from 1979. zsh added features but kept the fork-based C architecture. fish focused on UX and abandoned POSIX. nushell reinvented the data model but lost compatibility.

zshrs takes a different approach: keep everything that makes zsh powerful — glob qualifiers, parameter expansion flags, the completion system, ZLE, zstyle, modules — and replace the runtime with modern systems engineering. Rust instead of C. Thread pool instead of fork. rkyv mmap'd zero-copy archives instead of flat files. Bytecode VM instead of tree-walker. AOP instead of monkey-patching.

The result is the first shell that gets faster as you add more plugins, because the plugin cache means each plugin is only parsed once. The first shell where **/*.rs scales with your CPU count. The first shell where you can intercept any command with nanosecond-accurate timing and zero overhead.

The result is the first shell where every command — interactive or scripted — compiles to bytecodes and executes on a VM with fused superinstructions. The first shell where autoload functions load from pre-compiled bytecodes in microseconds. The first shell where source ~/.zshrc can skip the lexer, parser, and compiler entirely because the bytecodes are mmap'd zero-copy from rkyv archives the daemon already validated.

Since the Bourne shell at Bell Labs in 1970, through csh, ksh, bash, zsh, and fish — every Unix shell has been an interpreter. zshrs is the first to be a compiler. Shell scripts at machine code speed. Achieved in alpha.

THE FIRST COMPILED UNIX SHELL. THE MOST POWERFUL SHELL EVER CREATED.