#!/usr/bin/env zsh# ── pentesting.zsh : lazy loader for the curated toolkit ─────────────────────# Keeps boot fast (~170ms): the 3300-line toolkit in pentest-tools.zsh loads on# first use. Each toolkit command gets a thin wrapper that, on first call, loads# the real toolkit (which overwrites every wrapper) then dispatches. Wrappers are# real functions, so they work correctly under redirection/pipes — unlike a# command_not_found_handler, which zsh runs in a forked subshell when the missing# command is redirected (definitions there never persist)._PENTEST_TOOLS="${ZDOTDIR:-$HOME/.dotfiles}/config/pentest-tools.zsh"typeset -g _PENTEST_TOOLS_LOADED=[[ -r "${ZDOTDIR:-$HOME/.dotfiles}/config/pentest-cmds.zsh"]]&&\source"${ZDOTDIR:-$HOME/.dotfiles}/config/pentest-cmds.zsh"_load_pentest_tools(){[[ -n $_PENTEST_TOOLS_LOADED]]&&return0[[ -r $_PENTEST_TOOLS]]||return1_PENTEST_TOOLS_LOADED=1# set FIRST so a toolkit command running mid-source can't recurseunset PENTEST_LOADED # our loader is authoritative; ignore the toolkit's self-guardsource"$_PENTEST_TOOLS"}# Install a lazy wrapper for every toolkit command. First call to any of them# loads the toolkit (replacing all wrappers with the real definitions) then runs.(){local c
for c in$_PENTEST_CMDS; do(( $+functions[$c]))&&continue# never clobber an already-real fn (e.g. DB-owned) functions[$c]="_load_pentest_tools && $c \"\$@\""done}# explicit entry points (not toolkit functions themselves)pentest(){ _load_pentest_tools; (( $+functions[pentest-status]))&& pentest-status || pentest-help 2>/dev/null }