From 1c0491d0254010ec5f03e95ec37dfd3787a7595d Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Thu, 25 Dec 2025 16:03:15 -0500 Subject: [PATCH] Dotfiles update 2025-12-25 16:03 --- zsh/aliases.zsh | 278 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 203 insertions(+), 75 deletions(-) diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index b8adeaf..96f7d92 100644 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -1,97 +1,174 @@ # ============================================================================ -# Dotfiles Command Aliases - Extended Version +# Dotfiles Command Aliases # ============================================================================ -# Includes all original aliases plus new improvement aliases. +# All dotfiles-*.sh script aliases and the unified dotfiles-cli interface. +# +# Scripts covered: +# - dotfiles-doctor.sh Health check and auto-fix +# - dotfiles-sync.sh Git sync operations +# - dotfiles-update.sh Pull and reinstall +# - dotfiles-version.sh Version information +# - dotfiles-stats.sh Basic shell statistics +# - dotfiles-compile.sh Compile zsh files +# - dotfiles-vault.sh Secrets management +# - dotfiles-analytics.sh Enhanced history analytics +# - dotfiles-profile.sh Startup time profiling +# - dotfiles-diff.sh Diff and security audit +# - dotfiles-tour.sh Interactive tour / first-run # ============================================================================ -# Dotfiles directory +# Dotfiles directory reference _df_dir="${DOTFILES_DIR:-$HOME/.dotfiles}" _df_bin="$_df_dir/bin" -# Helper to run dotfiles scripts +# ============================================================================ +# Helper Function +# ============================================================================ + +# Run dotfiles script with fallback _df_run() { local script="$1" shift if [[ -x "$_df_bin/$script" ]]; then "$_df_bin/$script" "$@" + elif [[ -x "$HOME/.local/bin/$script" ]]; then + "$HOME/.local/bin/$script" "$@" elif command -v "$script" &>/dev/null; then "$script" "$@" else - echo "Error: $script not found" >&2 + echo "Error: $script not found in $_df_bin or PATH" >&2 return 1 fi } # ============================================================================ -# Quality of Life Aliases -# ============================================================================ - -alias hist="history" -alias cls="clear" -alias q="exit" - -# ============================================================================ -# Core Dotfiles Commands +# Navigation Aliases # ============================================================================ alias dfdir='cd $HOME/.dotfiles' alias c.='cd $HOME/.dotfiles' -# Doctor - health check +# ============================================================================ +# Doctor - Health Check +# ============================================================================ + dfd() { _df_run dotfiles-doctor.sh "$@"; } doctor() { _df_run dotfiles-doctor.sh "$@"; } dffix() { _df_run dotfiles-doctor.sh --fix "$@"; } -# Sync +# ============================================================================ +# Sync - Git Operations +# ============================================================================ + dfs() { _df_run dotfiles-sync.sh "$@"; } dfpush() { _df_run dotfiles-sync.sh push "${1:-Dotfiles update $(date '+%Y-%m-%d %H:%M')}"; } dfpull() { _df_run dotfiles-sync.sh pull "$@"; } dfstatus() { _df_run dotfiles-sync.sh status "$@"; } -# Update +# ============================================================================ +# Update - Pull & Reinstall +# ============================================================================ + dfu() { _df_run dotfiles-update.sh "$@"; } dfupdate() { _df_run dotfiles-update.sh "$@"; } +# ============================================================================ # Version +# ============================================================================ + dfv() { _df_run dotfiles-version.sh "$@"; } dfversion() { _df_run dotfiles-version.sh "$@"; } -# Stats / Analytics -dfstats() { _df_run dotfiles-stats.sh "$@"; } -dfanalytics() { _df_run dotfiles-analytics.sh "$@"; } +# ============================================================================ +# Stats - Basic Statistics +# ============================================================================ + +dfstats() { _df_run dotfiles-stats.sh "$@"; } + +# ============================================================================ +# Compile - Zsh Compilation +# ============================================================================ + +dfcompile() { _df_run dotfiles-compile.sh "$@"; } + +# ============================================================================ +# Vault - Secrets Management +# ============================================================================ -# Vault vault() { _df_run dotfiles-vault.sh "$@"; } vls() { _df_run dotfiles-vault.sh list "$@"; } vget() { _df_run dotfiles-vault.sh get "$@"; } vset() { _df_run dotfiles-vault.sh set "$@"; } -# Compile -dfcompile() { _df_run dotfiles-compile.sh "$@"; } +# ============================================================================ +# Analytics - Enhanced History Analytics +# ============================================================================ + +dfanalytics() { _df_run dotfiles-analytics.sh "$@"; } +alias analytics='dfanalytics' + +# Analytics subcommands +alias dfan='dfanalytics' +alias dfan-hourly='dfanalytics hourly' +alias dfan-weekly='dfanalytics weekly' +alias dfan-projects='dfanalytics projects' +alias dfan-trends='dfanalytics trends' +alias dfan-tools='dfanalytics tools' +alias dfan-suggest='dfanalytics suggestions' # ============================================================================ -# NEW: Profile & Performance +# Profile - Startup Time Profiling # ============================================================================ dfprofile() { _df_run dotfiles-profile.sh "$@"; } alias profile='dfprofile' alias startup-time='dfprofile --quick' +alias dfprof='dfprofile' + +# Profile subcommands +alias dfprof-detailed='dfprofile --detailed' +alias dfprof-benchmark='dfprofile --benchmark' +alias dfprof-compare='dfprofile --compare' +alias dfprof-tips='dfprofile --tips' # ============================================================================ -# NEW: Diff & Audit +# Diff - Changes & Security Audit # ============================================================================ dfdiff() { _df_run dotfiles-diff.sh "$@"; } dfaudit() { _df_run dotfiles-diff.sh --audit "$@"; } alias audit='dfaudit' +# Diff subcommands +alias dfdiff-installed='dfdiff --installed' +alias dfdiff-symlinks='dfdiff --symlinks' +alias dfdiff-secrets='dfdiff --secrets' +alias dfdiff-permissions='dfdiff --permissions' +alias dfdiff-machines='dfdiff --machines' + # ============================================================================ -# NEW: Tour & First-Run +# Tour - Interactive Help & First-Run # ============================================================================ dftour() { _df_run dotfiles-tour.sh "$@"; } alias tour='dftour' alias quickref='dftour --quick' +alias dfchangelog='dftour --changelog' + +# ============================================================================ +# Testing +# ============================================================================ + +dftest() { + local test_dir="${DOTFILES_DIR:-$HOME/.dotfiles}/tests" + if [[ -f "$test_dir/run-tests.zsh" ]]; then + zsh "$test_dir/run-tests.zsh" "$@" + else + echo "Test runner not found at $test_dir/run-tests.zsh" >&2 + return 1 + fi +} +alias test-dotfiles='dftest' # ============================================================================ # Quick Edit Aliases @@ -103,90 +180,136 @@ alias v.edit='cd ~/.dotfiles && ${EDITOR:-vim} .' alias v.alias='${EDITOR:-vim} ~/.dotfiles/zsh/aliases.zsh' alias v.motd='${EDITOR:-vim} ~/.dotfiles/zsh/functions/motd.zsh' alias v.theme='${EDITOR:-vim} ~/.dotfiles/zsh/themes/adlee.zsh-theme' - -# NEW: Edit machine config alias v.machine='${EDITOR:-vim} ~/.dotfiles/machines/${DF_HOSTNAME:-$(hostname -s)}.zsh' # ============================================================================ -# Reload Aliases +# Reload # ============================================================================ alias reload='source ~/.zshrc' alias rl='source ~/.zshrc' # ============================================================================ -# Dotfiles CLI +# Dotfiles CLI - Unified Interface # ============================================================================ dotfiles-cli() { case "${1:-help}" in - doctor|doc|d) shift; _df_run dotfiles-doctor.sh "$@" ;; - sync|s) shift; _df_run dotfiles-sync.sh "$@" ;; - update|up|u) shift; _df_run dotfiles-update.sh "$@" ;; - version|ver|v) shift; _df_run dotfiles-version.sh "$@" ;; - stats|st) shift; _df_run dotfiles-stats.sh "$@" ;; - analytics|an) shift; _df_run dotfiles-analytics.sh "$@" ;; - vault|vlt) shift; _df_run dotfiles-vault.sh "$@" ;; - compile|comp) shift; _df_run dotfiles-compile.sh "$@" ;; - profile|prof) shift; _df_run dotfiles-profile.sh "$@" ;; - diff|df) shift; _df_run dotfiles-diff.sh "$@" ;; - audit|aud) shift; _df_run dotfiles-diff.sh --audit "$@" ;; - tour|t) shift; _df_run dotfiles-tour.sh "$@" ;; - test) shift; zsh ~/.dotfiles/tests/run-tests.zsh "$@" ;; - edit|e) cd ~/.dotfiles && ${EDITOR:-vim} . ;; - cd) cd ~/.dotfiles ;; + # Core commands + doctor|doc|d) + shift; _df_run dotfiles-doctor.sh "$@" ;; + sync|s) + shift; _df_run dotfiles-sync.sh "$@" ;; + update|up|u) + shift; _df_run dotfiles-update.sh "$@" ;; + version|ver|v) + shift; _df_run dotfiles-version.sh "$@" ;; + stats|st) + shift; _df_run dotfiles-stats.sh "$@" ;; + compile|comp|c) + shift; _df_run dotfiles-compile.sh "$@" ;; + vault|vlt) + shift; _df_run dotfiles-vault.sh "$@" ;; + + # New commands + analytics|an) + shift; _df_run dotfiles-analytics.sh "$@" ;; + profile|prof|p) + shift; _df_run dotfiles-profile.sh "$@" ;; + diff|df) + shift; _df_run dotfiles-diff.sh "$@" ;; + audit|aud|a) + shift; _df_run dotfiles-diff.sh --audit "$@" ;; + tour|t) + shift; _df_run dotfiles-tour.sh "$@" ;; + test) + shift; dftest "$@" ;; + + # Navigation + edit|e) + cd "${DOTFILES_DIR:-$HOME/.dotfiles}" && ${EDITOR:-vim} . ;; + cd) + cd "${DOTFILES_DIR:-$HOME/.dotfiles}" ;; + + # Help help|--help|-h|*) cat << 'EOF' -Dotfiles CLI - Extended +Dotfiles CLI - Unified Interface Usage: dotfiles-cli [args] + dfc [args] Core Commands: doctor, d Health check (--fix to repair) - sync, s Sync dotfiles across machines + sync, s Git sync (push/pull/status) update, u Pull latest and reinstall version, v Show version info - stats, st Basic shell analytics + stats, st Basic shell statistics + compile, c Compile zsh files for speed vault, vlt Secrets management - compile Compile zsh files for speed -New Commands: - analytics, an Enhanced shell analytics - profile, prof Startup time profiling - diff, df Show changes and compare - audit, aud Security audit - tour, t Interactive tour / help +Analytics & Diagnostics: + analytics, an Enhanced history analytics + Subcommands: hourly, weekly, projects, trends, tools, suggestions + profile, p Startup time profiling + Options: --quick, --detailed, --benchmark, --compare, --tips + diff, df Show uncommitted changes + Options: --installed, --symlinks, --secrets, --permissions + audit, a Full security audit + +Help & Testing: + tour, t Interactive tour / first-run experience + Options: --quick (reference card), --changelog test Run test suite Navigation: edit, e Open dotfiles in editor cd Change to dotfiles directory -Aliases: dfd, dffix, dfs, dfpush, dfpull, dfu, dfv, dfstats, vault - dfprofile, dfdiff, dfaudit, dftour +Quick Aliases: + dfd doctor + dffix doctor --fix + dfs sync + dfpush sync push + dfpull sync pull + dfu update + dfv version + dfstats stats + dfcompile compile + vault vault + dfanalytics analytics + dfprofile profile + dfdiff diff + dfaudit audit + dftour tour + dftest test + +Examples: + dfc doctor --fix # Health check with auto-fix + dfc sync push # Push changes to remote + dfc analytics weekly # Show weekly usage patterns + dfc profile --tips # Get startup optimization tips + dfc audit # Run full security audit + dfc tour --quick # Show quick reference card EOF ;; esac } +# Short alias for dotfiles-cli alias dfc='dotfiles-cli' # ============================================================================ -# System Utilities +# Convenience Aliases # ============================================================================ -# Use glow for markdown -alias glow='glow -p' -less() { - if command -v glow &>/dev/null && [[ $# -eq 1 && "$1" == *.md ]]; then - glow -p "$1" - else - command less "$@" - fi -} +# Quality of life +alias hist="history" +alias cls="clear" +alias q="exit" -# Arch system upgrade with snapper +# System upgrade with snapshot (Arch/CachyOS) sys-update() { local update_date=$(date +"%Y-%m-%d %H:%M") if command -v snapper &>/dev/null; then @@ -194,13 +317,18 @@ sys-update() { else sudo pacman -Syu fi - # Update package count for prompt + # Update package count for prompt if available command -v checkupdates &>/dev/null && export UPDATE_PKG_COUNT=$(checkupdates 2>/dev/null | wc -l) } -# ============================================================================ -# Testing -# ============================================================================ - -alias dftest='zsh ~/.dotfiles/tests/run-tests.zsh' -alias test-dotfiles='dftest' +# Markdown viewer with glow +if command -v glow &>/dev/null; then + alias glow='glow -p' + less() { + if [[ $# -eq 1 && "$1" == *.md ]]; then + glow -p "$1" + else + command less "$@" + fi + } +fi