# Modular ZSH / tmux / Pentest Environment Rebuild — Design Spec
Date: 2026-06-07
Status: Approved (design), pending spec review
Repo: `~/.dotfiles`
## 1. Goal
Rebuild the user's mature-but-slow zsh environment into a clean, modular, fast,
cross-platform dotfiles project with a new SQLite-backed engagement tracker,
non-blocking animated fetch, an upgraded tmux config, setup/bootstrap scripts,
and comprehensive docs. Preserve the Chi-Rho "Neon Glow" rice aesthetic.
## 2. Locked decisions
| Decision | Choice |
|---|---|
| Treatment of existing config | Full modular rebuild (not augment) |
| Migration fidelity | Curated rebuild — keep what's used, drop dead/dupes, show cut list first |
| Shell framework | **Drop oh-my-zsh** → lightweight loader |
| Plugin loader | Dependency-free manual loader (clone + source), cached single `compinit` |
| Animated fetch | Custom ANSI frame-loop, non-blocking — integrate existing `crossfetch` |
| Credential storage | Plaintext SQLite + 600 perms + warnings + gitignore |
| Platform | macOS + Linux parity (brew/apt detect, mac vs kali/pwnbox paths) |
| Emojis | **None.** Nerd-font glyphs only (per user memory) |
| Pride/seasonal code | None anywhere (hyfetch not used) |
## 3. Current-state findings (audit basis)
- `.zshrc` — 2370 lines, 114 funcs, 151 aliases. Sources OMZ + fzf + atuin + zsh-abbr + lazy pentest.
- `.pentest.zsh` — 2886 lines, ~120 funcs. **Already lazy-loaded** via `_load_pentest` + `command_not_found_handler` for `htb-*`. Preserve this pattern.
- `.pentest-mac.zsh` — 402 lines, 11 funcs (Docker-Kali env).
- `.tmux.conf` — 149 lines (enhance, not replace).
- `~/.config/starship.toml` — Chi-Rho rice (keep, add target segment).
- `~/.config/fastfetch/config.jsonc` + `cross.txt` — Chi-Rho logo.
- `~/.local/bin/crossfetch` — animated orbiting-ring dashboard (`cross`, `CROSS_MODE`, `CROSS_TIMEOUT`). Integrate.
- `~/.pentest/` — does not exist yet (new DB home).
### Performance bugs identified
1. **Double `compinit`** — once in `oh-my-zsh.sh`, once in the Docker block (`autoload -Uz compinit; compinit`).
2. **24 OMZ plugins** loaded eagerly every shell.
3. Eager `fastfetch` + optional `crossfetch` splash blocks the prompt.
4. `ZSH_THEME=""` dead leftover.
## 4. Repo & file layout
```
~/.dotfiles/
.zshrc thin orchestrator: env guard → source config/*.zsh in order
.tmux.conf
config/
core.zsh env, PATH, perf, loader, compinit, completions, history
theme.zsh starship init + transience + active-target segment
pentesting.zsh curated toolkit (lazy), + pentest-mac (Docker-Kali)
database.zsh SQLite engagement tracker (htb-newbox/creds/flags/...)
aliases.zsh eza l* family, nav, encode, http, msf, cleanup
functions.zsh h* forensic/file, git helpers, cheat, OMZ-builtin reimpls
animations.zsh crossfetch integration + fastfetch static, verse, git-welcome
plugins/ cloned zsh plugins (gitignored or submodule)
scripts/
setup.sh OS detect, deps, backup, symlink, db-init, perms, self-test
update.sh pull repo, update plugins, re-link, re-test
db-init.sql schema
db-backup.sh cron-able tar.gz backup
docs/
CHEATSHEET.md PENTESTING.md DATABASE.md TMUX.md
superpowers/specs/ this spec
README.md
.gitignore ignores ~/.pentest data, plugins/, local secrets
```
`setup.sh` backs up existing `~/.zshrc`, `~/.tmux.conf`, `~/.pentest.zsh`,
`~/.pentest-mac.zsh` to `~/.dotfiles-backup-<timestamp>/`, then symlinks
`~/.dotfiles/.zshrc → ~/.zshrc` and `~/.dotfiles/.tmux.conf → ~/.tmux.conf`.
### Load order (in `.zshrc`)
1. Interactive guard + instant-prompt-safe env
2. `core.zsh` (PATH/env/history/compinit/loader/plugins)
3. `aliases.zsh`, `functions.zsh`
4. `theme.zsh` (starship)
5. `database.zsh` (defines functions only; no DB I/O at startup)
6. `pentesting.zsh` lazy wrapper (load on first `htb`/`pentest`/`htb-*`)
7. `animations.zsh` splash (non-blocking, last, interactive-only)
## 5. core.zsh — performance
- Drop OMZ. Manual loader sources 6 plugins from `config/plugins/`:
zsh-autosuggestions, fast-syntax-highlighting (or zsh-syntax-highlighting),
zsh-completions, zsh-history-substring-search, fzf-tab, you-should-use.
- Single cached `compinit`: rebuild dump only if older than ~24h (`-C` fast path).
- Reimplement used OMZ built-ins as small functions/widgets in functions.zsh:
`extract`/`x`, sudo-ESC-ESC widget, `copypath`, `copyfile`, dirhistory
(Alt+arrows), web-search, encode64 (`b64*` already aliased), urltools,
colored-man-pages (LESS_TERMCAP env), command-not-found handler (merged with
pentest lazy-load handler).
- Keep atuin (async init), zsh-abbr, fzf keybindings, HOMEBREW_NO_AUTO_UPDATE.
- Perf target: **< 2 s to interactive** hard cap; aim ~300 ms to first prompt
with the splash running non-blocking after.
## 6. theme.zsh — prompt + engagement context
- Keep starship + `enable_transience`. Replace emoji warning with nerd glyph.
- Add one custom starship segment (`[custom.target]`) that shows
` <box>@<ip>` when active, hidden otherwise. Source of truth:
`~/.pentest/.active` (single line `name|ip`), also exported as
`$PENTEST_TARGET` / `$PENTEST_TARGET_IP`. tmux status bar reads the same file.
## 7. database.zsh + db-init.sql — engagement tracker (net-new core)
DB: `~/.pentest/engagements.db`, dir `0700`, file `0600`, gitignored.
First-run banner warns: plaintext lab loot, not for real-world sensitive data.
### Schema
```sql
CREATE TABLE IF NOT EXISTS targets (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE,
ip TEXT,
os TEXT,
status TEXT DEFAULT 'active',
created_at TEXT DEFAULT (datetime('now')),
notes TEXT
);
CREATE TABLE IF NOT EXISTS credentials (
id INTEGER PRIMARY KEY AUTOINCREMENT,
target_id INTEGER REFERENCES targets(id) ON DELETE CASCADE,
username TEXT, password TEXT, service TEXT DEFAULT 'unknown',
found_at TEXT DEFAULT (datetime('now')), notes TEXT
);
CREATE TABLE IF NOT EXISTS flags (
id INTEGER PRIMARY KEY AUTOINCREMENT,
target_id INTEGER REFERENCES targets(id) ON DELETE CASCADE,
flag_type TEXT CHECK(flag_type IN ('user','root')),
flag_value TEXT, found_at TEXT DEFAULT (datetime('now'))
);
CREATE TABLE IF NOT EXISTS findings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
target_id INTEGER REFERENCES targets(id) ON DELETE CASCADE,
title TEXT, severity TEXT, description TEXT, evidence TEXT,
found_at TEXT DEFAULT (datetime('now'))
);
CREATE TABLE IF NOT EXISTS notes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
target_id INTEGER REFERENCES targets(id) ON DELETE CASCADE,
body TEXT, created_at TEXT DEFAULT (datetime('now'))
);
```
`PRAGMA foreign_keys = ON;` on every connection.
### Command reference (replaces old file-based creds/flag/note)
- `htb-newbox <name> <ip>` — insert target row + create box dir (merges existing `htb-box`) + set active.
- `htb-list` — table of targets.
- `htb-select <name>` — set `~/.pentest/.active` + env.
- `creds add <user> <pass> [service] [notes]` / `creds list` — uses active target.
- `flags add <flag> [user|root]` / `flags list`.
- `findings add <title> <severity> <description> [evidence]` / `findings list`.
- `note add <text>` / `note list`.
- `database show` — engagement summary. `database backup [name]` — tar.gz to `~/.pentest/backups/`.
`database restore <file>`. `database export` — markdown report to `~/.pentest/reports/`.
`database delete` — **typed confirmation + auto-backup first**.
- Input passed via sqlite parameterized/quoted-safe helper to avoid SQL-injection on quotes.
## 8. animations.zsh — non-blocking splash
- Reuse `crossfetch` (already non-blocking, ring/rain/both, timeout-bounded).
- Default interactive splash: short bounded intro (respect `CROSS_TIMEOUT`,
skippable by keypress), then static `fastfetch`. Toggle `ANIM_SPLASH`/`CROSS_SPLASH`.
- Keep `verse` (Isaiah line), `_git_welcome`. No emoji, no pride/seasonal code.
## 9. pentesting.zsh — curated toolkit
Curated port of `.pentest.zsh` + `.pentest-mac.zsh`, lazy-loaded (preserve
`_load_pentest` + merged `command_not_found_handler`). Groups: target mgmt,
scanning (nmap/rustscan + `rs*` family), web enum, AD/Windows (impacket/nxc/
certipy/bloodhound), cracking (hashcat/hydra/john), listeners/shells/revshell,
C2 (sliver/havoc), pivoting (chisel/ligolo/socks), HTB box/lab/Docker mgmt,
OSINT. Remove file-based `note/flag/flag-count/flags/creds/creds-show` (→ DB).
Optional: collapse the ~80 `rs*` wrappers into one `rs <profile>` dispatcher
(kept as backward-compat aliases) — flagged for user decision in the plan.
## 10. .tmux.conf — enhancements over existing 149 lines
tpm + tmux-resurrect + tmux-continuum. Neon Glow status bar with live target
context (reads `~/.pentest/.active`). Pentest 4-pane layout bind
(recon | exploit / notes | shells). `tmux-htb <box>` session template. Mouse on,
vi copy-mode, sane pane nav, reload bind. Keep user's existing working binds.
## 11. scripts
- `setup.sh` — detect OS (Darwin/Linux + distro), install deps (brew vs apt:
zsh, tmux, git, sqlite3, fastfetch, fzf, eza, starship, atuin, plugin repos),
backup existing configs, symlink dotfiles, clone plugins, run `db-init.sql`,
set perms (`~/.pentest` 700, db 600), self-test (`zsh -ic 'exit'` timing + DB ping).
- `update.sh` — `git pull`, update plugin clones, re-link, re-test.
- `db-backup.sh` — tar.gz `~/.pentest` to `~/.pentest/backups/<ts>.tar.gz`, prune old.
## 12. docs
- `CHEATSHEET.md` — aliases, nav, file/forensic, encode, http, cleanup.
- `PENTESTING.md` — toolkit by CPTS phase + Docker-Kali env.
- `DATABASE.md` — engagement workflow + full HTB walkthrough example.
- `TMUX.md` — binds, layouts, session templates.
- `README.md` — install (setup.sh), structure, toggles, troubleshooting.
## 13. Security model
Plaintext SQLite (lab loot). `~/.pentest` 700, db 600, gitignored. Warning
banner on first `creds add`. Auto-backup before `database delete`/`restore`.
No secrets in repo. Quote/escape all SQL string inputs.
## 14. Keep / Cut audit
### CUT (certain)
- `oh-my-zsh.sh` source + 24-plugin array → lightweight loader.
- Double `compinit` (Docker block) → single cached compinit.
- `ZSH_THEME=""` (dead after OMZ drop).
- File-based `note` / `flag` / `flag-count` / `flags` / `creds` / `creds-show`
in `.pentest.zsh` → superseded by `database.zsh`.
- 18 OMZ built-in plugins → reimplement only the used subset (extract, sudo,
copypath, copyfile, dirhistory, web-search, encode64, urltools, colored-man-pages).
- Emoji warnings (`⚠️` etc.) → nerd glyphs.
- Stale-path comment cruft in fish-ported block.
### KEEP & remap
- `cross`/`crossmode` + crossfetch + fastfetch + `verse` + `_git_welcome` → animations.zsh
- `l*` eza family (~50), nav (`..`/`...`), `b64*`, url-encode/decode, http-*, msf*, cleanup* → aliases.zsh
- `h*` forensic/file (~30), `gcommit*`, `glastupdate`, `update-all`, `cheat`/`_cheat_quick` → functions.zsh
- starship init + transience (+ new target segment) → theme.zsh
- `rs*` rustscan family (~80), `rustscan`, `john*`, all `.pentest.zsh` toolkit groups, `.pentest-mac.zsh` → pentesting.zsh
- `htb-box`/`box`/`lab` dir mgmt → pentesting.zsh, integrated with DB `htb-newbox`
### DECIDE during plan
- Collapse `rs*` family into `rs <profile>` dispatcher? (back-compat aliases kept either way)
- fast-syntax-highlighting vs zsh-syntax-highlighting.
## 15. Testing / verification
- Startup timing: `for i in 1..5; do time zsh -ic exit; done`, assert < 2 s.
- DB: create temp DB, run full command cycle (newbox→creds→flags→findings→export→backup→restore→delete), assert rows + report.
- Lint: `zsh -n` each module; `shellcheck` scripts.
- tmux: `tmux -f .tmux.conf new -d` loads without error.
- setup.sh dry-run path on macOS; Linux path validated by branch review.
## 16. Out of scope (YAGNI)
- Encrypted DB (SQLCipher/age) — revisit if data sensitivity changes.
- hyfetch.
- Replacing starship with a custom prompt.
- Windows support.
- Multi-user / team sync of the DB.