Dotfiles update 2025-12-25 12:04

This commit is contained in:
Aaron D. Lee
2025-12-25 12:04:56 -05:00
parent 4695b1e410
commit afb9c78c9b
71 changed files with 8163 additions and 758 deletions

View File

@@ -0,0 +1,119 @@
#!/usr/bin/env zsh
# ============================================================================
# Dotfiles Compile - Pre-compile zsh files for faster loading
# ============================================================================
set -e
# Source bootstrap
source "${DOTFILES_HOME:-$HOME/.dotfiles}/zsh/lib/bootstrap.zsh" 2>/dev/null || {
DF_GREEN=$'\033[0;32m' DF_YELLOW=$'\033[1;33m' DF_CYAN=$'\033[0;36m'
DF_NC=$'\033[0m'
DOTFILES_HOME="${DOTFILES_HOME:-$HOME/.dotfiles}"
df_print_header() { echo "=== $1 ==="; }
df_print_success() { echo -e "${DF_GREEN}${DF_NC} $1"; }
}
# ============================================================================
# Functions
# ============================================================================
compile_file() {
local file="$1"
if [[ -f "$file" ]]; then
if [[ ! -f "${file}.zwc" ]] || [[ "$file" -nt "${file}.zwc" ]]; then
if zcompile "$file" 2>/dev/null; then
echo -e "${DF_GREEN}${DF_NC} Compiled: ${file##*/}"
else
echo -e "${DF_YELLOW}${DF_NC} Skipped: ${file##*/}"
fi
else
echo -e "${DF_CYAN}${DF_NC} Current: ${file##*/}"
fi
fi
}
clean_compiled() {
echo "Removing compiled files..."
local count=0
# Remove .zwc files in dotfiles directory
for zwc in "$DOTFILES_HOME"/**/*.zwc(N); do
rm -f "$zwc"
((count++))
done
# Remove home directory compiled files
rm -f ~/.zshrc.zwc ~/.zshenv.zwc ~/.zprofile.zwc 2>/dev/null
echo -e "${DF_GREEN}${DF_NC} Removed $count compiled files"
}
compile_all() {
echo -e "${DF_CYAN}Compiling zsh files for faster startup...${DF_NC}"
echo ""
echo "Core files:"
compile_file ~/.zshrc
compile_file ~/.zshenv
compile_file ~/.zprofile
echo ""
echo "Dotfiles:"
compile_file "$DOTFILES_HOME/zsh/.zshrc"
compile_file "$DOTFILES_HOME/zsh/aliases.zsh"
# Lib files
for file in "$DOTFILES_HOME/zsh/lib"/*.zsh(N); do
compile_file "$file"
done
# Function files
for file in "$DOTFILES_HOME/zsh/functions"/*.zsh(N); do
compile_file "$file"
done
# Theme files
for file in "$DOTFILES_HOME/zsh/themes"/*.zsh-theme(N); do
compile_file "$file"
done
echo ""
# Oh-My-Zsh (optional)
if [[ -d ~/.oh-my-zsh ]]; then
echo "Oh-My-Zsh (optional):"
compile_file ~/.oh-my-zsh/oh-my-zsh.sh
echo ""
fi
echo -e "${DF_GREEN}${DF_NC} Compilation complete"
echo ""
echo "To measure startup time:"
echo " time zsh -i -c exit"
echo " hyperfine 'zsh -i -c exit' # More accurate"
}
show_help() {
echo "Usage: dotfiles-compile.sh [OPTIONS]"
echo ""
echo "Compile zsh files to bytecode for faster shell startup."
echo ""
echo "Options:"
echo " (none) Compile all zsh files"
echo " --clean Remove all compiled (.zwc) files"
echo " --help Show this help"
}
# ============================================================================
# Main
# ============================================================================
df_print_header "dotfiles-compile"
case "${1:-}" in
--clean|-c) clean_compiled ;;
--help|-h) show_help ;;
*) compile_all ;;
esac

View File

@@ -0,0 +1,256 @@
#!/usr/bin/env bash
# ============================================================================
# Dotfiles Health Check (Arch/CachyOS)
# ============================================================================
# Usage:
# dotfiles-doctor.sh # Run all checks
# dotfiles-doctor.sh --fix # Attempt automatic fixes
# dotfiles-doctor.sh --quick # Quick essential checks only
# ============================================================================
# Source bootstrap (provides colors, config, and utility functions)
source "${DOTFILES_HOME:-$HOME/.dotfiles}/zsh/lib/bootstrap.zsh" 2>/dev/null || {
echo "Warning: bootstrap.zsh not found, using fallbacks"
DF_RED=$'\033[0;31m' DF_GREEN=$'\033[0;32m' DF_YELLOW=$'\033[1;33m'
DF_BLUE=$'\033[0;34m' DF_CYAN=$'\033[0;36m' DF_NC=$'\033[0m'
DOTFILES_HOME="${DOTFILES_HOME:-$HOME/.dotfiles}"
df_print_header() { echo "=== $1 ==="; }
df_print_success() { echo -e "${DF_GREEN}${DF_NC} $1"; }
df_print_error() { echo -e "${DF_RED}${DF_NC} $1" >&2; }
df_print_warning() { echo -e "${DF_YELLOW}${DF_NC} $1"; }
}
# ============================================================================
# Parse Arguments
# ============================================================================
DO_FIX=false
QUICK_MODE=false
for arg in "$@"; do
case "$arg" in
--fix) DO_FIX=true ;;
--quick) QUICK_MODE=true ;;
--help|-h)
echo "Usage: dotfiles-doctor.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --fix Attempt automatic fixes for issues"
echo " --quick Run quick essential checks only"
echo " --help Show this help"
exit 0
;;
esac
done
# ============================================================================
# Tracking Variables
# ============================================================================
TOTAL_CHECKS=0
PASSED_CHECKS=0
FAILED_CHECKS=0
WARNING_CHECKS=0
FIXED_CHECKS=0
# ============================================================================
# Check Helper Functions
# ============================================================================
print_section() { echo -e "\n${DF_BLUE}${DF_NC} $1"; }
check_pass() {
((PASSED_CHECKS++))
((TOTAL_CHECKS++))
echo -e " ${DF_GREEN}${DF_NC} $1"
}
check_fail() {
((FAILED_CHECKS++))
((TOTAL_CHECKS++))
echo -e " ${DF_RED}${DF_NC} $1"
}
check_warn() {
((WARNING_CHECKS++))
((TOTAL_CHECKS++))
echo -e " ${DF_YELLOW}${DF_NC} $1"
}
check_fixed() {
((FIXED_CHECKS++))
echo -e " ${DF_CYAN}${DF_NC} Fixed: $1"
}
# ============================================================================
# Check Functions
# ============================================================================
check_os() {
print_section "Operating System"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if grep -qi "cachyos" /etc/os-release 2>/dev/null; then
check_pass "Running CachyOS"
elif grep -qi "arch" /etc/os-release 2>/dev/null; then
check_pass "Running Arch Linux"
else
check_fail "Not running on Arch/CachyOS"
fi
else
check_fail "Not running on Linux"
fi
check_pass "Kernel: $(uname -r)"
}
check_shell() {
print_section "Shell Configuration"
[[ -f "$HOME/.zshrc" ]] && check_pass "Zsh configuration exists" || check_fail "Zsh configuration missing"
[[ "$SHELL" == *"zsh"* ]] && check_pass "Zsh is default shell" || check_warn "Zsh is not default shell"
if command -v zsh &>/dev/null; then
check_pass "Zsh version: $(zsh --version | awk '{print $2}')"
fi
}
check_symlinks() {
print_section "Symlinks"
local symlinks=(
"$HOME/.zshrc"
"$HOME/.gitconfig"
"$HOME/.vimrc"
"$HOME/.tmux.conf"
)
for symlink in "${symlinks[@]}"; do
if [[ -L "$symlink" ]]; then
if [[ -e "$symlink" ]]; then
check_pass "$(basename "$symlink")$(readlink "$symlink")"
else
check_fail "$(basename "$symlink") is broken symlink"
if [[ "$DO_FIX" == true ]]; then
rm "$symlink"
check_fixed "Removed broken symlink: $(basename "$symlink")"
fi
fi
elif [[ -f "$symlink" ]]; then
check_warn "$(basename "$symlink") is regular file (not symlink)"
fi
done
}
check_pacman() {
print_section "Package Manager"
if ! command -v pacman &>/dev/null; then
check_fail "Pacman not found"
return
fi
check_pass "Pacman available"
if command -v paru &>/dev/null; then
check_pass "AUR helper: paru"
elif command -v yay &>/dev/null; then
check_pass "AUR helper: yay"
else
check_warn "No AUR helper installed (paru or yay recommended)"
fi
}
check_optional_tools() {
print_section "Optional Tools"
local tools=("fzf" "bat" "eza" "tmux" "nvim")
for tool in "${tools[@]}"; do
command -v "$tool" &>/dev/null && check_pass "$tool" || check_warn "$tool not installed"
done
}
check_dotfiles_dir() {
print_section "Dotfiles Directory"
if [[ ! -d "$DOTFILES_HOME" ]]; then
check_fail "Dotfiles not found"
return
fi
check_pass "Dotfiles: $DOTFILES_HOME"
[[ -f "$DOTFILES_HOME/dotfiles.conf" ]] && check_pass "Config file exists" || check_warn "Config file missing"
[[ -d "$DOTFILES_HOME/.git" ]] && check_pass "Git repo initialized" || check_warn "Not a git repository"
check_pass "Version: ${DOTFILES_VERSION:-unknown}"
check_pass "Display width: ${DF_WIDTH:-66}"
}
check_bin_scripts() {
print_section "Bin Scripts"
local scripts=(
"dotfiles-doctor.sh"
"dotfiles-sync.sh"
"dotfiles-update.sh"
"dotfiles-version.sh"
)
for script in "${scripts[@]}"; do
if [[ -x "$HOME/.local/bin/$script" ]]; then
check_pass "$script"
elif [[ -f "$HOME/.local/bin/$script" ]]; then
check_warn "$script exists but not executable"
if [[ "$DO_FIX" == true ]]; then
chmod +x "$HOME/.local/bin/$script"
check_fixed "Made executable: $script"
fi
else
check_fail "$script not linked"
fi
done
}
# ============================================================================
# Summary
# ============================================================================
print_summary() {
local width="${DF_WIDTH:-66}"
echo ""
printf "${DF_CYAN}─%.0s${DF_NC}" $(seq 1 "$width")
echo ""
if [[ $FAILED_CHECKS -eq 0 ]]; then
echo -e "${DF_GREEN}${DF_NC} All checks passed ($PASSED_CHECKS/$TOTAL_CHECKS)"
else
echo -e "${DF_RED}${DF_NC} Issues found: $FAILED_CHECKS failed, $WARNING_CHECKS warnings"
fi
[[ $FIXED_CHECKS -gt 0 ]] && echo -e "${DF_CYAN}${DF_NC} Auto-fixed: $FIXED_CHECKS issues"
echo ""
}
# ============================================================================
# Main
# ============================================================================
main() {
df_print_header "dotfiles-doctor"
check_os
check_pacman
check_shell
check_dotfiles_dir
check_symlinks
if [[ "$QUICK_MODE" != true ]]; then
check_optional_tools
check_bin_scripts
fi
print_summary
}
main "$@"

View File

@@ -0,0 +1,110 @@
#!/usr/bin/env bash
# ============================================================================
# Dotfiles Shell Analytics (Arch/CachyOS)
# ============================================================================
set -e
# Source bootstrap
source "${DOTFILES_HOME:-$HOME/.dotfiles}/zsh/lib/bootstrap.zsh" 2>/dev/null || {
DF_RED=$'\033[0;31m' DF_GREEN=$'\033[0;32m' DF_YELLOW=$'\033[1;33m'
DF_BLUE=$'\033[0;34m' DF_CYAN=$'\033[0;36m' DF_MAGENTA=$'\033[0;35m'
DF_NC=$'\033[0m'
df_print_header() { echo "=== $1 ==="; }
}
# ============================================================================
# Helper Functions
# ============================================================================
print_section() {
echo ""
echo -e "${DF_BLUE}${DF_NC} $1"
echo -e "${DF_CYAN}─────────────────────────────────────────────────────────────${DF_NC}"
}
get_history() {
if [[ -f "$HOME/.zsh_history" ]]; then
# Handle zsh extended history format
grep -I "^:" "$HOME/.zsh_history" 2>/dev/null | cut -d';' -f2 || cat "$HOME/.zsh_history"
elif [[ -f "$HOME/.bash_history" ]]; then
cat "$HOME/.bash_history"
fi
}
# ============================================================================
# Analytics Functions
# ============================================================================
show_dashboard() {
print_section "Command History Dashboard"
local total=$(get_history | wc -l)
local unique=$(get_history | sort -u | wc -l)
echo -e " ${DF_CYAN}Total Commands:${DF_NC} $total"
echo -e " ${DF_CYAN}Unique Commands:${DF_NC} $unique"
echo ""
print_section "Top 15 Commands"
get_history | awk '{print $1}' | sort | uniq -c | sort -rn | head -15 | while read count cmd; do
printf " %-25s ${DF_GREEN}%5d${DF_NC}\n" "$cmd" "$count"
done
echo ""
}
show_top() {
local count="${1:-20}"
print_section "Top $count Commands"
get_history | awk '{print $1}' | sort | uniq -c | sort -rn | head -"$count" | while read cnt cmd; do
printf " %-25s ${DF_GREEN}%5d${DF_NC}\n" "$cmd" "$cnt"
done
}
show_git_stats() {
print_section "Git Command Breakdown"
get_history | grep "^git " | awk '{print $2}' | sort | uniq -c | sort -rn | head -10 | while read count subcmd; do
printf " git %-20s ${DF_GREEN}%5d${DF_NC}\n" "$subcmd" "$count"
done
}
show_dirs() {
print_section "Most Visited Directories"
get_history | grep "^cd " | awk '{print $2}' | sort | uniq -c | sort -rn | head -10 | while read count dir; do
printf " %-30s ${DF_GREEN}%5d${DF_NC}\n" "$dir" "$count"
done
}
show_help() {
echo "Usage: dotfiles-stats.sh [COMMAND]"
echo ""
echo "Commands:"
echo " dashboard Full analytics dashboard (default)"
echo " top [n] Top N commands (default: 20)"
echo " git Git command breakdown"
echo " dirs Most visited directories"
echo " help Show this help"
}
# ============================================================================
# Main
# ============================================================================
main() {
df_print_header "dotfiles-stats"
case "${1:-dashboard}" in
dashboard) show_dashboard ;;
top) show_top "${2:-20}" ;;
git) show_git_stats ;;
dirs) show_dirs ;;
help|--help|-h) show_help ;;
*)
echo "Unknown command: $1"
show_help
exit 1
;;
esac
}
main "$@"

View File

@@ -0,0 +1,162 @@
#!/usr/bin/env bash
# ============================================================================
# Dotfiles Synchronization (Arch/CachyOS)
# ============================================================================
set -e
# Source bootstrap (provides colors, config, and utility functions)
source "${DOTFILES_HOME:-$HOME/.dotfiles}/zsh/lib/bootstrap.zsh" 2>/dev/null || {
DF_RED=$'\033[0;31m' DF_GREEN=$'\033[0;32m' DF_YELLOW=$'\033[1;33m'
DF_BLUE=$'\033[0;34m' DF_CYAN=$'\033[0;36m' DF_NC=$'\033[0m'
DOTFILES_HOME="${DOTFILES_HOME:-$HOME/.dotfiles}"
df_print_header() { echo "=== $1 ==="; }
df_print_success() { echo -e "${DF_GREEN}${DF_NC} $1"; }
df_print_error() { echo -e "${DF_RED}${DF_NC} $1" >&2; }
df_print_warning() { echo -e "${DF_YELLOW}${DF_NC} $1"; }
}
# ============================================================================
# Helper Functions
# ============================================================================
print_status() { echo -e "${DF_CYAN}${DF_NC} $1"; }
print_section() { echo ""; echo -e "${DF_BLUE}${DF_NC} $1"; }
# ============================================================================
# Sync Functions
# ============================================================================
check_git_repo() {
if ! git -C "$DOTFILES_HOME" rev-parse --git-dir > /dev/null 2>&1; then
df_print_error "Not a git repository: $DOTFILES_HOME"
exit 1
fi
}
get_sync_status() {
cd "$DOTFILES_HOME"
local local_commits=$(git rev-list --count @{u}..HEAD 2>/dev/null || echo 0)
local remote_commits=$(git rev-list --count HEAD..@{u} 2>/dev/null || echo 0)
echo "$local_commits:$remote_commits"
}
show_status() {
print_section "Sync Status"
cd "$DOTFILES_HOME"
print_status "Local branch: $(git rev-parse --abbrev-ref HEAD)"
print_status "Last commit: $(git log -1 --pretty=format:'%h - %s' 2>/dev/null || echo 'N/A')"
local status=$(get_sync_status)
local local_commits="${status%:*}"
local remote_commits="${status#*:}"
echo ""
[[ $local_commits -gt 0 ]] && df_print_warning "$local_commits commit(s) ahead of remote"
[[ $remote_commits -gt 0 ]] && df_print_warning "$remote_commits commit(s) behind remote"
[[ $local_commits -eq 0 && $remote_commits -eq 0 ]] && df_print_success "In sync with remote"
}
show_status_short() {
cd "$DOTFILES_HOME"
local changes=$(git status --porcelain | wc -l)
local status=$(get_sync_status)
local local_commits="${status%:*}"
local remote_commits="${status#*:}"
if [[ $changes -gt 0 ]]; then
echo -e " ${DF_YELLOW}${DF_NC} Dotfiles: ${changes} local change(s) not pushed"
elif [[ $local_commits -gt 0 ]]; then
echo -e " ${DF_YELLOW}${DF_NC} Dotfiles: ${local_commits} commit(s) not pushed"
elif [[ $remote_commits -gt 0 ]]; then
echo -e " ${DF_YELLOW}${DF_NC} Dotfiles: ${remote_commits} commit(s) behind remote"
fi
}
pull_changes() {
print_section "Pulling Changes"
cd "$DOTFILES_HOME"
print_status "Fetching from remote..."
git fetch origin
if git pull origin; then
df_print_success "Changes pulled"
else
df_print_success "Already up to date"
fi
}
push_changes() {
local commit_msg="$1"
print_section "Pushing Changes"
cd "$DOTFILES_HOME"
if ! git status --porcelain | grep -q .; then
df_print_warning "No local changes to push"
return
fi
print_status "Staging changes..."
git add -A
if [[ -z "$commit_msg" ]]; then
read -p "Commit message: " commit_msg
[[ -z "$commit_msg" ]] && { df_print_error "Commit cancelled"; return 1; }
fi
git commit -m "$commit_msg"
git push origin
df_print_success "Changes pushed"
}
# ============================================================================
# Main
# ============================================================================
main() {
check_git_repo
case "${1:-status}" in
status)
if [[ "$2" == "-s" || "$2" == "--short" ]]; then
show_status_short
else
df_print_header "dotfiles-sync"
show_status
fi
;;
push)
df_print_header "dotfiles-sync"
shift
push_changes "$*"
;;
pull)
df_print_header "dotfiles-sync"
pull_changes
;;
-s|--short)
show_status_short
;;
--help|-h)
echo "Usage: dotfiles-sync.sh [COMMAND]"
echo ""
echo "Commands:"
echo " status [-s] Show sync status (default)"
echo " push [message] Push changes to remote"
echo " pull Pull changes from remote"
echo ""
echo "Options:"
echo " -s, --short Short status output"
echo " --help Show this help"
;;
*)
echo "Unknown command: $1"
echo "Use --help for usage information"
exit 1
;;
esac
}
main "$@"

View File

@@ -0,0 +1,79 @@
#!/usr/bin/env bash
# ============================================================================
# Update Dotfiles Script
# ============================================================================
set -e
# ============================================================================
# Parse Arguments First (before sourcing, in case we need --help)
# ============================================================================
SKIP_DEPS=true
PULL_ONLY=false
for arg in "$@"; do
case "$arg" in
--skip-deps) SKIP_DEPS=true ;;
--with-deps) SKIP_DEPS=false ;;
--pull-only) PULL_ONLY=true ;;
--help|-h)
echo "Usage: dotfiles-update.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --skip-deps Skip dependency check (default for updates)"
echo " --with-deps Run full dependency check"
echo " --pull-only Only git pull, don't re-run install script"
echo " --help Show this help message"
exit 0
;;
esac
done
# ============================================================================
# Source Bootstrap
# ============================================================================
source "${DOTFILES_HOME:-$HOME/.dotfiles}/zsh/lib/bootstrap.zsh" 2>/dev/null || {
DF_GREEN=$'\033[0;32m' DF_YELLOW=$'\033[1;33m' DF_RED=$'\033[0;31m'
DF_CYAN=$'\033[0;36m' DF_NC=$'\033[0m'
DOTFILES_HOME="${DOTFILES_HOME:-$HOME/.dotfiles}"
DOTFILES_BRANCH="${DOTFILES_BRANCH:-main}"
df_print_header() { echo "=== $1 ==="; }
df_print_success() { echo -e "${DF_GREEN}${DF_NC} $1"; }
df_print_error() { echo -e "${DF_RED}${DF_NC} $1" >&2; }
df_print_warning() { echo -e "${DF_YELLOW}${DF_NC} $1"; }
df_print_step() { echo -e "${DF_GREEN}==>${DF_NC} $1"; }
}
# ============================================================================
# Main
# ============================================================================
df_print_header "dotfiles-update"
if [[ ! -d "$DOTFILES_HOME" ]]; then
df_print_error "Dotfiles directory not found: $DOTFILES_HOME"
exit 1
fi
cd "$DOTFILES_HOME"
df_print_step "Updating dotfiles from repository..."
if git pull origin "${DOTFILES_BRANCH:-main}"; then
df_print_success "Dotfiles updated successfully"
if [[ "$PULL_ONLY" == true ]]; then
echo ""
df_print_success "Pull complete (--pull-only mode)"
exit 0
fi
echo ""
df_print_success "Update complete!"
echo -e "Reload your shell: ${DF_CYAN}reload${DF_NC} or ${DF_CYAN}source ~/.zshrc${DF_NC}"
else
df_print_error "Failed to update dotfiles"
exit 1
fi

View File

@@ -0,0 +1,138 @@
#!/usr/bin/env bash
# ============================================================================
# Dotfiles Secrets Vault (Arch/CachyOS)
# ============================================================================
set -e
# Source bootstrap
source "${DOTFILES_HOME:-$HOME/.dotfiles}/zsh/lib/bootstrap.zsh" 2>/dev/null || {
DF_RED=$'\033[0;31m' DF_GREEN=$'\033[0;32m' DF_YELLOW=$'\033[1;33m'
DF_BLUE=$'\033[0;34m' DF_CYAN=$'\033[0;36m' DF_NC=$'\033[0m'
DOTFILES_HOME="${DOTFILES_HOME:-$HOME/.dotfiles}"
df_print_header() { echo "=== $1 ==="; }
df_print_success() { echo -e "${DF_GREEN}${DF_NC} $1"; }
df_print_error() { echo -e "${DF_RED}${DF_NC} $1" >&2; }
}
# ============================================================================
# Configuration
# ============================================================================
readonly VAULT_DIR="${DOTFILES_HOME}/vault"
readonly VAULT_FILE="${VAULT_DIR}/secrets.enc"
# ============================================================================
# Helper Functions
# ============================================================================
print_section() { echo ""; echo -e "${DF_BLUE}${DF_NC} $1"; }
get_cipher() {
if command -v age &>/dev/null; then
echo "age"
elif command -v gpg &>/dev/null; then
echo "gpg"
else
df_print_error "No encryption tool available (install 'age' or 'gpg')"
exit 1
fi
}
# ============================================================================
# Vault Functions
# ============================================================================
init_vault() {
print_section "Initializing Vault"
mkdir -p "$VAULT_DIR"
chmod 700 "$VAULT_DIR"
if [[ ! -f "$VAULT_FILE" ]]; then
echo "{}" > "$VAULT_FILE"
df_print_success "Vault initialized at $VAULT_DIR"
else
df_print_success "Vault already exists"
fi
}
vault_list() {
print_section "Stored Secrets"
if [[ ! -f "$VAULT_FILE" ]]; then
df_print_error "No vault file found. Run: vault init"
return 1
fi
local keys=$(cat "$VAULT_FILE" | grep -o '"[^"]*":' | sed 's/"//g;s/:$//')
if [[ -z "$keys" ]]; then
echo " (no secrets stored)"
else
echo "$keys" | while read key; do
echo -e " ${DF_CYAN}${DF_NC} $key"
done
fi
echo ""
}
vault_status() {
print_section "Vault Status"
if [[ ! -d "$VAULT_DIR" ]]; then
echo -e " ${DF_YELLOW}${DF_NC} Vault not initialized"
echo " Run: vault init"
return
fi
if [[ ! -f "$VAULT_FILE" ]]; then
echo -e " ${DF_YELLOW}${DF_NC} Vault file not found"
return
fi
local cipher=$(get_cipher)
local key_count=$(cat "$VAULT_FILE" | grep -o '"[^"]*":' | wc -l)
echo -e " ${DF_CYAN}Location:${DF_NC} $VAULT_FILE"
echo -e " ${DF_CYAN}Encryption:${DF_NC} $cipher"
echo -e " ${DF_CYAN}Secrets:${DF_NC} $key_count"
echo ""
}
show_help() {
echo "Usage: dotfiles-vault.sh [COMMAND]"
echo ""
echo "Commands:"
echo " init Initialize the vault"
echo " list, ls List all secret keys"
echo " status Show vault status"
echo " help Show this help"
echo ""
echo "The vault uses 'age' or 'gpg' for encryption."
}
# ============================================================================
# Main
# ============================================================================
main() {
df_print_header "dotfiles-vault"
# Auto-init if vault doesn't exist
[[ ! -d "$VAULT_DIR" ]] && init_vault
case "${1:-list}" in
init) init_vault ;;
list|ls) vault_list ;;
status) vault_status ;;
help|--help|-h) show_help ;;
*)
echo "Unknown command: $1"
show_help
exit 1
;;
esac
}
main "$@"

View File

@@ -0,0 +1,88 @@
#!/usr/bin/env bash
# ============================================================================
# Dotfiles Version Checker
# ============================================================================
# ============================================================================
# Parse Arguments First
# ============================================================================
CHECK_ONLY=false
for arg in "$@"; do
case "$arg" in
--check|-c) CHECK_ONLY=true ;;
--help|-h)
echo "Usage: dotfiles-version.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --check, -c Output version only (for scripts)"
echo " --help Show this help"
exit 0
;;
esac
done
# ============================================================================
# Source Bootstrap
# ============================================================================
source "${DOTFILES_HOME:-$HOME/.dotfiles}/zsh/lib/bootstrap.zsh" 2>/dev/null || {
DF_GREEN=$'\033[0;32m' DF_CYAN=$'\033[0;36m' DF_NC=$'\033[0m'
DOTFILES_HOME="${DOTFILES_HOME:-$HOME/.dotfiles}"
DOTFILES_VERSION="${DOTFILES_VERSION:-unknown}"
DOTFILES_BRANCH="${DOTFILES_BRANCH:-main}"
DF_WIDTH="${DF_WIDTH:-66}"
df_print_header() { echo "=== $1 ==="; }
}
# ============================================================================
# Version Info Functions
# ============================================================================
get_local_commit() {
if [[ -d "${DOTFILES_HOME}/.git" ]]; then
cd "$DOTFILES_HOME"
git rev-parse --short HEAD 2>/dev/null || echo "unknown"
else
echo "not a git repo"
fi
}
get_local_date() {
if [[ -d "${DOTFILES_HOME}/.git" ]]; then
cd "$DOTFILES_HOME"
git log -1 --format="%ci" 2>/dev/null | cut -d' ' -f1 || echo "unknown"
else
echo "unknown"
fi
}
# ============================================================================
# Main
# ============================================================================
main() {
local local_commit=$(get_local_commit)
local local_date=$(get_local_date)
# Short output for scripts
if [[ "$CHECK_ONLY" == true ]]; then
echo "Version: ${DOTFILES_VERSION} (${local_commit})"
exit 0
fi
# Full output
df_print_header "dotfiles-version"
echo -e "${DF_CYAN}Local:${DF_NC}"
echo -e " Version: ${DF_GREEN}${DOTFILES_VERSION}${DF_NC}"
echo -e " Commit: ${local_commit}"
echo -e " Date: ${local_date}"
echo -e " Path: ${DOTFILES_HOME}"
echo -e " Branch: ${DOTFILES_BRANCH}"
echo -e " Width: ${DF_WIDTH}"
echo ""
}
main "$@"