Skip to content

πŸ› οΈ ZSHAND Functions ReferenceΒΆ

πŸ“‹ Reusable utility functions loaded at startup. Available in every terminal session. Each function file includes a documentation header with USAGE, DEPENDENCIES, EXAMPLES, and SEE ALSO.


πŸ›€οΈ Path FunctionsΒΆ

Function Usage Purpose
add_path add_path ~/bin Safely add to PATH (-a append, -r recursive)
zpath zpath Audit PATH, fpath, manpath
pathfix pathfix Audit and repair PATH (missing dirs, duplicates)

πŸ”€ Git FunctionsΒΆ

Function Usage Purpose
tossh tossh [dir] Convert GitHub HTTPS remotes to SSH
gundo gundo Git undo menu (unstage, soft reset, squash, hard reset)
gitprune gitprune Delete merged local branches
_gitid (chpwd hook) Auto Git identity from project .env

πŸ–₯️ System FunctionsΒΆ

Function Usage Purpose
health health Environment health check (cache, runtimes, Atuin, SSH, clipboard, disk)
pkgsync pkgsync Verify package sync (core + optional, MCHOSE bins, clipboard)
zports zports [term] Active network listeners (lsof)
ztop ztop Workstation dashboard (uptime, Git, cache, zpulse)
extract extract <file> Universal archive extraction (optional delete source)
zopt zopt [pattern] List Zsh options (optional filter)
tog tog <option> Toggle Zsh option on/off (e.g. tog autocd)

πŸ”§ Helper FunctionsΒΆ

Function Usage Purpose
dcopy dcopy Copy CWD path to clipboard
fcopy fcopy <file> Copy file contents to clipboard
zbak zbak <file> Timestamped backup to .backups
fnew fnew <name> Create function stub and open in editor
google google "query" Open Google search in browser
jfmt jfmt [file] Pretty-print JSON (file or stdin)
seek seek "pattern" Search zshand files (ripgrep)

πŸ“Š Logging FunctionsΒΆ

Function Usage Purpose
zlog zlog [cmd] View session log (summary, -t, -list, -clean, failed, search)
logstat logstat 30-day log statistics (commands, success rate, top commands)
bootlog bootlog [view\|tail\|clear\|path] Shell init log viewer

πŸ“š Reference FunctionsΒΆ

Function Usage Purpose
zhelp zhelp Master command reference
zwidgets zwidgets Keyboard map (widget bindings)

✏️ Adding Custom Functions¢

  1. Create ~/.config/zshand/functions/my_func.zsh:
# ── my_func β€” Short description ──────────────────────────────────────────────
#
# USAGE:
#   my_func [args]
#
# ─────────────────────────────────────────────────────────────────────────────

my_func() {
    local arg="${1:-default}"
    echo "Processing: $arg"
}
  1. Rebuild: zr
  2. Use it: my_func value

πŸ“ Naming ConventionsΒΆ

  • No prefix β€” user-facing functions (dcopy, health, seek)
  • z prefix β€” framework-related (zpath, zlog, zopt, ztop)
  • _ prefix β€” internal/hook-only (_gitid, _zlog_viewer)
  • .zsh extension β€” sourced at startup, no shebang needed

πŸ”€ Override BehaviorΒΆ

User functions with the same basename replace framework functions:

~/.config/zshand/functions/seek.zsh  β†’  replaces $ZSHAND/functions/seek.zsh
~/.config/zshand/functions/my_new.zsh  β†’  added alongside framework functions

Document Purpose
πŸ“‚ functions/README.md In-tree quick reference
πŸ—οΈ ARCHITECTURE.md Function loading in boot sequence
🎨 STYLE_GUIDE.md Naming and code conventions
πŸ‘€ USER_CONFIG.md Custom functions directory
πŸ“ HEADER_STANDARD.md Function file header format