Dotfiles update 2025-12-25 16:03

This commit is contained in:
Aaron D. Lee
2025-12-25 16:03:15 -05:00
parent a3101a9f61
commit 1c0491d025

View File

@@ -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_dir="${DOTFILES_DIR:-$HOME/.dotfiles}"
_df_bin="$_df_dir/bin" _df_bin="$_df_dir/bin"
# Helper to run dotfiles scripts # ============================================================================
# Helper Function
# ============================================================================
# Run dotfiles script with fallback
_df_run() { _df_run() {
local script="$1" local script="$1"
shift shift
if [[ -x "$_df_bin/$script" ]]; then if [[ -x "$_df_bin/$script" ]]; then
"$_df_bin/$script" "$@" "$_df_bin/$script" "$@"
elif [[ -x "$HOME/.local/bin/$script" ]]; then
"$HOME/.local/bin/$script" "$@"
elif command -v "$script" &>/dev/null; then elif command -v "$script" &>/dev/null; then
"$script" "$@" "$script" "$@"
else else
echo "Error: $script not found" >&2 echo "Error: $script not found in $_df_bin or PATH" >&2
return 1 return 1
fi fi
} }
# ============================================================================ # ============================================================================
# Quality of Life Aliases # Navigation Aliases
# ============================================================================
alias hist="history"
alias cls="clear"
alias q="exit"
# ============================================================================
# Core Dotfiles Commands
# ============================================================================ # ============================================================================
alias dfdir='cd $HOME/.dotfiles' alias dfdir='cd $HOME/.dotfiles'
alias c.='cd $HOME/.dotfiles' alias c.='cd $HOME/.dotfiles'
# Doctor - health check # ============================================================================
# Doctor - Health Check
# ============================================================================
dfd() { _df_run dotfiles-doctor.sh "$@"; } dfd() { _df_run dotfiles-doctor.sh "$@"; }
doctor() { _df_run dotfiles-doctor.sh "$@"; } doctor() { _df_run dotfiles-doctor.sh "$@"; }
dffix() { _df_run dotfiles-doctor.sh --fix "$@"; } dffix() { _df_run dotfiles-doctor.sh --fix "$@"; }
# Sync # ============================================================================
# Sync - Git Operations
# ============================================================================
dfs() { _df_run dotfiles-sync.sh "$@"; } dfs() { _df_run dotfiles-sync.sh "$@"; }
dfpush() { _df_run dotfiles-sync.sh push "${1:-Dotfiles update $(date '+%Y-%m-%d %H:%M')}"; } dfpush() { _df_run dotfiles-sync.sh push "${1:-Dotfiles update $(date '+%Y-%m-%d %H:%M')}"; }
dfpull() { _df_run dotfiles-sync.sh pull "$@"; } dfpull() { _df_run dotfiles-sync.sh pull "$@"; }
dfstatus() { _df_run dotfiles-sync.sh status "$@"; } dfstatus() { _df_run dotfiles-sync.sh status "$@"; }
# Update # ============================================================================
# Update - Pull & Reinstall
# ============================================================================
dfu() { _df_run dotfiles-update.sh "$@"; } dfu() { _df_run dotfiles-update.sh "$@"; }
dfupdate() { _df_run dotfiles-update.sh "$@"; } dfupdate() { _df_run dotfiles-update.sh "$@"; }
# ============================================================================
# Version # Version
# ============================================================================
dfv() { _df_run dotfiles-version.sh "$@"; } dfv() { _df_run dotfiles-version.sh "$@"; }
dfversion() { _df_run dotfiles-version.sh "$@"; } dfversion() { _df_run dotfiles-version.sh "$@"; }
# Stats / Analytics # ============================================================================
dfstats() { _df_run dotfiles-stats.sh "$@"; } # Stats - Basic Statistics
dfanalytics() { _df_run dotfiles-analytics.sh "$@"; } # ============================================================================
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 "$@"; } vault() { _df_run dotfiles-vault.sh "$@"; }
vls() { _df_run dotfiles-vault.sh list "$@"; } vls() { _df_run dotfiles-vault.sh list "$@"; }
vget() { _df_run dotfiles-vault.sh get "$@"; } vget() { _df_run dotfiles-vault.sh get "$@"; }
vset() { _df_run dotfiles-vault.sh set "$@"; } 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 "$@"; } dfprofile() { _df_run dotfiles-profile.sh "$@"; }
alias profile='dfprofile' alias profile='dfprofile'
alias startup-time='dfprofile --quick' 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 "$@"; } dfdiff() { _df_run dotfiles-diff.sh "$@"; }
dfaudit() { _df_run dotfiles-diff.sh --audit "$@"; } dfaudit() { _df_run dotfiles-diff.sh --audit "$@"; }
alias audit='dfaudit' 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 "$@"; } dftour() { _df_run dotfiles-tour.sh "$@"; }
alias tour='dftour' alias tour='dftour'
alias quickref='dftour --quick' 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 # 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.alias='${EDITOR:-vim} ~/.dotfiles/zsh/aliases.zsh'
alias v.motd='${EDITOR:-vim} ~/.dotfiles/zsh/functions/motd.zsh' alias v.motd='${EDITOR:-vim} ~/.dotfiles/zsh/functions/motd.zsh'
alias v.theme='${EDITOR:-vim} ~/.dotfiles/zsh/themes/adlee.zsh-theme' 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' alias v.machine='${EDITOR:-vim} ~/.dotfiles/machines/${DF_HOSTNAME:-$(hostname -s)}.zsh'
# ============================================================================ # ============================================================================
# Reload Aliases # Reload
# ============================================================================ # ============================================================================
alias reload='source ~/.zshrc' alias reload='source ~/.zshrc'
alias rl='source ~/.zshrc' alias rl='source ~/.zshrc'
# ============================================================================ # ============================================================================
# Dotfiles CLI # Dotfiles CLI - Unified Interface
# ============================================================================ # ============================================================================
dotfiles-cli() { dotfiles-cli() {
case "${1:-help}" in case "${1:-help}" in
doctor|doc|d) shift; _df_run dotfiles-doctor.sh "$@" ;; # Core commands
sync|s) shift; _df_run dotfiles-sync.sh "$@" ;; doctor|doc|d)
update|up|u) shift; _df_run dotfiles-update.sh "$@" ;; shift; _df_run dotfiles-doctor.sh "$@" ;;
version|ver|v) shift; _df_run dotfiles-version.sh "$@" ;; sync|s)
stats|st) shift; _df_run dotfiles-stats.sh "$@" ;; shift; _df_run dotfiles-sync.sh "$@" ;;
analytics|an) shift; _df_run dotfiles-analytics.sh "$@" ;; update|up|u)
vault|vlt) shift; _df_run dotfiles-vault.sh "$@" ;; shift; _df_run dotfiles-update.sh "$@" ;;
compile|comp) shift; _df_run dotfiles-compile.sh "$@" ;; version|ver|v)
profile|prof) shift; _df_run dotfiles-profile.sh "$@" ;; shift; _df_run dotfiles-version.sh "$@" ;;
diff|df) shift; _df_run dotfiles-diff.sh "$@" ;; stats|st)
audit|aud) shift; _df_run dotfiles-diff.sh --audit "$@" ;; shift; _df_run dotfiles-stats.sh "$@" ;;
tour|t) shift; _df_run dotfiles-tour.sh "$@" ;; compile|comp|c)
test) shift; zsh ~/.dotfiles/tests/run-tests.zsh "$@" ;; shift; _df_run dotfiles-compile.sh "$@" ;;
edit|e) cd ~/.dotfiles && ${EDITOR:-vim} . ;; vault|vlt)
cd) cd ~/.dotfiles ;; 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|*) help|--help|-h|*)
cat << 'EOF' cat << 'EOF'
Dotfiles CLI - Extended Dotfiles CLI - Unified Interface
Usage: dotfiles-cli <command> [args] Usage: dotfiles-cli <command> [args]
dfc <command> [args]
Core Commands: Core Commands:
doctor, d Health check (--fix to repair) 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 update, u Pull latest and reinstall
version, v Show version info 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 vault, vlt Secrets management
compile Compile zsh files for speed
New Commands: Analytics & Diagnostics:
analytics, an Enhanced shell analytics analytics, an Enhanced history analytics
profile, prof Startup time profiling Subcommands: hourly, weekly, projects, trends, tools, suggestions
diff, df Show changes and compare profile, p Startup time profiling
audit, aud Security audit Options: --quick, --detailed, --benchmark, --compare, --tips
tour, t Interactive tour / help 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 test Run test suite
Navigation: Navigation:
edit, e Open dotfiles in editor edit, e Open dotfiles in editor
cd Change to dotfiles directory cd Change to dotfiles directory
Aliases: dfd, dffix, dfs, dfpush, dfpull, dfu, dfv, dfstats, vault Quick Aliases:
dfprofile, dfdiff, dfaudit, dftour 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 EOF
;; ;;
esac esac
} }
# Short alias for dotfiles-cli
alias dfc='dotfiles-cli' alias dfc='dotfiles-cli'
# ============================================================================ # ============================================================================
# System Utilities # Convenience Aliases
# ============================================================================ # ============================================================================
# Use glow for markdown # Quality of life
alias glow='glow -p' alias hist="history"
less() { alias cls="clear"
if command -v glow &>/dev/null && [[ $# -eq 1 && "$1" == *.md ]]; then alias q="exit"
glow -p "$1"
else
command less "$@"
fi
}
# Arch system upgrade with snapper # System upgrade with snapshot (Arch/CachyOS)
sys-update() { sys-update() {
local update_date=$(date +"%Y-%m-%d %H:%M") local update_date=$(date +"%Y-%m-%d %H:%M")
if command -v snapper &>/dev/null; then if command -v snapper &>/dev/null; then
@@ -194,13 +317,18 @@ sys-update() {
else else
sudo pacman -Syu sudo pacman -Syu
fi 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) command -v checkupdates &>/dev/null && export UPDATE_PKG_COUNT=$(checkupdates 2>/dev/null | wc -l)
} }
# ============================================================================ # Markdown viewer with glow
# Testing if command -v glow &>/dev/null; then
# ============================================================================ alias glow='glow -p'
less() {
alias dftest='zsh ~/.dotfiles/tests/run-tests.zsh' if [[ $# -eq 1 && "$1" == *.md ]]; then
alias test-dotfiles='dftest' glow -p "$1"
else
command less "$@"
fi
}
fi