diff --git a/README.md b/README.md index 3d976e5..17bbadf 100644 --- a/README.md +++ b/README.md @@ -58,19 +58,26 @@ dotfiles/ ├── dotfiles.conf # Central configuration ├── zsh/ │ ├── .zshrc # Shell config +│ ├── aliases.zsh # Dotfiles command aliases │ ├── themes/adlee.zsh-theme │ └── functions/ │ ├── snapper.zsh # Btrfs snapshots │ ├── smart-suggest.zsh # Typo correction -│ └── command-palette.zsh +│ ├── command-palette.zsh +│ ├── motd.zsh # Dynamic MOTD +│ └── password-manager.zsh ├── espanso/ # Text expansion │ └── match/base.yml # 100+ snippets -├── bin/ # Utility scripts -│ ├── setup-wizard.sh # TUI installer +├── bin/ # Core scripts (linked to ~/.local/bin) │ ├── dotfiles-doctor.sh # Health checker │ ├── dotfiles-sync.sh # Multi-machine sync -│ ├── shell-stats.sh # Analytics -│ └── vault.sh # Secrets manager +│ ├── dotfiles-stats.sh # Shell analytics +│ ├── dotfiles-update.sh # Update dotfiles +│ ├── dotfiles-vault.sh # Secrets manager +│ └── dotfiles-version.sh # Version info +├── setup/ # Setup scripts (not linked) +│ ├── setup-wizard.sh # TUI installer +│ └── setup-espanso.sh # Espanso personalization ├── git/.gitconfig.template ├── vim/.vimrc ├── tmux/.tmux.conf @@ -142,7 +149,10 @@ Running: git status ## 📊 Shell Analytics ```bash -shell-stats.sh +dotfiles-stats.sh +# or use aliases: +dfstats +stats ``` ``` @@ -160,10 +170,10 @@ shell-stats.sh ``` ```bash -shell-stats.sh --suggest # Alias suggestions -shell-stats.sh --heatmap # Activity by hour -shell-stats.sh --git # Git breakdown -shell-stats.sh --dirs # Most visited directories +dotfiles-stats.sh --suggest # Alias suggestions +dotfiles-stats.sh --heatmap # Activity by hour +dotfiles-stats.sh --git # Git breakdown +dotfiles-stats.sh --dirs # Most visited directories ``` ## 🔐 Secrets Vault @@ -176,6 +186,7 @@ vault set AWS_SECRET_KEY # Prompts (hidden input) vault get GITHUB_TOKEN vault list # Shows keys only vault delete OLD_KEY +# Full command: dotfiles-vault.sh ``` Export to environment: @@ -275,6 +286,7 @@ Full list: [docs/ESPANSO.md](docs/ESPANSO.md) ```bash dotfiles-doctor.sh # Run diagnostics dotfiles-doctor.sh --fix # Auto-fix issues +# Aliases: dfd, doctor, dffix ``` ``` @@ -318,17 +330,37 @@ DOTFILES_AUTO_SYNC_CHECK="true" ## 🔄 Updating ```bash -cd ~/.dotfiles && git pull && ./install.sh -# or -update-dotfiles.sh +dotfiles-update.sh +# or aliases: +dfu +dfupdate ``` Check version: ```bash dotfiles-version.sh +# or: dfv ``` +## 🎯 Command Aliases + +All dotfiles commands have convenient aliases: + +| Alias | Command | Description | +|-------|---------|-------------| +| `dfd` | `dotfiles-doctor.sh` | Health check | +| `dffix` | `dotfiles-doctor.sh --fix` | Auto-fix issues | +| `dfs` | `dotfiles-sync.sh` | Sync dotfiles | +| `dfpush` | `dotfiles-sync.sh --push` | Push changes | +| `dfpull` | `dotfiles-sync.sh --pull` | Pull changes | +| `dfu` | `dotfiles-update.sh` | Update dotfiles | +| `dfv` | `dotfiles-version.sh` | Version info | +| `dfstats` | `dotfiles-stats.sh` | Shell analytics | +| `vault` | `dotfiles-vault.sh` | Secrets manager | +| `reload` | `source ~/.zshrc` | Reload shell | +| `dfc` | `dotfiles-cli` | CLI with subcommands | + ## 🗑️ Uninstalling ```bash diff --git a/aliases.zsh b/aliases.zsh new file mode 100644 index 0000000..7d9441e --- /dev/null +++ b/aliases.zsh @@ -0,0 +1,91 @@ +# ============================================================================ +# Dotfiles Command Aliases +# ============================================================================ +# Convenient shortcuts for dotfiles management scripts +# +# Source this file in .zshrc (already included by default) +# ============================================================================ + +# --- Core Dotfiles Commands --- +alias dotfiles='cd ~/.dotfiles' +alias df='cd ~/.dotfiles' + +# Doctor - health check +alias dfd='dotfiles-doctor.sh' +alias doctor='dotfiles-doctor.sh' +alias dffix='dotfiles-doctor.sh --fix' + +# Sync - multi-machine synchronization +alias dfs='dotfiles-sync.sh' +alias dfsync='dotfiles-sync.sh' +alias dfpush='dotfiles-sync.sh --push' +alias dfpull='dotfiles-sync.sh --pull' +alias dfstatus='dotfiles-sync.sh --status' + +# Update - pull latest and reinstall +alias dfu='dotfiles-update.sh' +alias dfupdate='dotfiles-update.sh' + +# Version - check version info +alias dfv='dotfiles-version.sh' +alias dfversion='dotfiles-version.sh' + +# Stats - shell analytics +alias dfstats='dotfiles-stats.sh' +alias stats='dotfiles-stats.sh' +alias tophist='dotfiles-stats.sh --top' +alias suggest='dotfiles-stats.sh --suggest' + +# Vault - secrets management +alias vault='dotfiles-vault.sh' +alias vls='dotfiles-vault.sh list' +alias vget='dotfiles-vault.sh get' +alias vset='dotfiles-vault.sh set' + +# --- Quick Edit Aliases --- +alias zshrc='${EDITOR:-vim} ~/.zshrc' +alias dfconf='${EDITOR:-vim} ~/.dotfiles/dotfiles.conf' +alias dfedit='cd ~/.dotfiles && ${EDITOR:-vim} .' + +# --- Reload Aliases --- +alias reload='source ~/.zshrc' +alias rl='source ~/.zshrc' + +# ============================================================================ +# Function Wrappers (for tab completion) +# ============================================================================ + +# Dotfiles main command with subcommands +dotfiles-cli() { + case "${1:-help}" in + doctor|doc|d) shift; dotfiles-doctor.sh "$@" ;; + sync|s) shift; dotfiles-sync.sh "$@" ;; + update|up|u) shift; dotfiles-update.sh "$@" ;; + version|ver|v) shift; dotfiles-version.sh "$@" ;; + stats|st) shift; dotfiles-stats.sh "$@" ;; + vault|vlt) shift; dotfiles-vault.sh "$@" ;; + edit|e) cd ~/.dotfiles && ${EDITOR:-vim} . ;; + cd) cd ~/.dotfiles ;; + help|--help|-h|*) + echo "Dotfiles CLI" + echo + echo "Usage: dotfiles-cli [args]" + echo + echo "Commands:" + echo " doctor, d Run health check (--fix to auto-repair)" + echo " sync, s Sync dotfiles across machines" + echo " update, u Pull latest and reinstall" + echo " version, v Show version info" + echo " stats, st Shell analytics dashboard" + echo " vault, vlt Secrets management" + echo " edit, e Open dotfiles in editor" + echo " cd Change to dotfiles directory" + echo + echo "Aliases:" + echo " dfd, dffix, dfs, dfpush, dfpull, dfu, dfv, dfstats, vault" + ;; + esac +} + +# Short alias for the CLI +alias dfc='dotfiles-cli' diff --git a/bin/deploy-zshtheme-systemwide.sh b/bin/deploy-zshtheme-systemwide.sh deleted file mode 100755 index f115ba9..0000000 --- a/bin/deploy-zshtheme-systemwide.sh +++ /dev/null @@ -1,347 +0,0 @@ -#!/usr/bin/env bash -# ============================================================================ -# ADLee Theme System-wide Deployment Script -# ============================================================================ -# Deploys the zsh theme system-wide via symlinks -# -# Usage: -# sudo ./deploy-zshtheme-systemwide.sh # Interactive mode -# sudo ./deploy-zshtheme-systemwide.sh --all # All users with oh-my-zsh -# sudo ./deploy-zshtheme-systemwide.sh --current # Current user + root only -# sudo ./deploy-zshtheme-systemwide.sh --status # Show deployment status -# sudo ./deploy-zshtheme-systemwide.sh --force # Force replace existing links - -set -euo pipefail - -# ============================================================================ -# Load Configuration -# ============================================================================ - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -DOTFILES_CONF="${SCRIPT_DIR}/../dotfiles.conf" -[[ -f "$DOTFILES_CONF" ]] || DOTFILES_CONF="$HOME/.dotfiles/dotfiles.conf" - -if [[ -f "$DOTFILES_CONF" ]]; then - source "$DOTFILES_CONF" -else - DOTFILES_DIR="$HOME/.dotfiles" - ZSH_THEME_NAME="adlee" -fi - -# ============================================================================ -# Configuration -# ============================================================================ - -MASTER_THEME_DIR="/usr/local/share/zsh/themes" -THEME_FILE="${ZSH_THEME_NAME}.zsh-theme" -MASTER_THEME_PATH="${MASTER_THEME_DIR}/${THEME_FILE}" -SOURCE_THEME="${DOTFILES_DIR}/zsh/themes/${THEME_FILE}" -FORCE_REPLACE=false - -# Colors -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -RED='\033[0;31m' -BLUE='\033[0;34m' -CYAN='\033[0;36m' -NC='\033[0m' - -# ============================================================================ -# Helper Functions -# ============================================================================ - -print_success() { echo -e "${GREEN}✓${NC} $1"; } -print_warning() { echo -e "${YELLOW}⚠${NC} $1"; } -print_error() { echo -e "${RED}✗${NC} $1"; } -print_info() { echo -e "${CYAN}ℹ${NC} $1"; } -print_step() { echo -e "\n${GREEN}==>${NC} $1"; } - -print_header() { - echo -e "\n${BLUE}╔════════════════════════════════════════════════════════════╗${NC}" - echo -e "${BLUE}║${NC} ${ZSH_THEME_NAME} Theme System-wide Deployment ${BLUE}║${NC}" - echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}\n" -} - -check_root() { - if [[ $EUID -ne 0 ]]; then - print_error "This script must be run as root (use sudo)" - echo "Usage: sudo $0 [--all|--current|--status]" - exit 1 - fi -} - -ask_yes_no() { - local prompt="$1" - local default="${2:-y}" - - if [[ "$default" == "y" ]]; then - prompt="$prompt [Y/n]: " - else - prompt="$prompt [y/N]: " - fi - - read -p "$prompt" response - response=${response:-$default} - [[ "$response" =~ ^[Yy]$ ]] -} - -is_system_symlink() { - local path="$1" - [[ -L "$path" ]] && [[ "$(readlink -f "$path")" == "$MASTER_THEME_PATH" ]] -} - -is_local_symlink() { - local path="$1" - if [[ -L "$path" ]]; then - local target=$(readlink -f "$path") - [[ "$target" == *"/.dotfiles/"* ]] - else - return 1 - fi -} - -get_link_status() { - local path="$1" - - if [[ ! -e "$path" ]] && [[ ! -L "$path" ]]; then - echo "not_present" - elif is_system_symlink "$path"; then - echo "system_link" - elif is_local_symlink "$path"; then - echo "local_link" - elif [[ -f "$path" ]] && [[ ! -L "$path" ]]; then - echo "regular_file" - elif [[ -L "$path" ]]; then - echo "other_link" - else - echo "unknown" - fi -} - -# ============================================================================ -# Setup Functions -# ============================================================================ - -setup_master_location() { - print_step "Setting up master theme location" - - [[ ! -d "$MASTER_THEME_DIR" ]] && mkdir -p "$MASTER_THEME_DIR" && print_success "Created: $MASTER_THEME_DIR" - - local source_file="" - [[ -f "$SOURCE_THEME" ]] && source_file="$SOURCE_THEME" - [[ -z "$source_file" && -f "$THEME_FILE" ]] && source_file="$THEME_FILE" - [[ -z "$source_file" && -f "$HOME/.oh-my-zsh/themes/$THEME_FILE" ]] && source_file="$HOME/.oh-my-zsh/themes/$THEME_FILE" - - if [[ -f "$MASTER_THEME_PATH" ]]; then - print_info "Master theme exists: $MASTER_THEME_PATH" - if [[ -n "$source_file" ]] && ! diff -q "$source_file" "$MASTER_THEME_PATH" &>/dev/null; then - print_warning "Source differs from master" - if ask_yes_no "Update master theme?"; then - cp "$source_file" "$MASTER_THEME_PATH" - chmod 644 "$MASTER_THEME_PATH" - print_success "Master theme updated" - fi - fi - else - if [[ -z "$source_file" ]]; then - print_error "Theme file not found. Check these locations:" - echo " - $SOURCE_THEME" - echo " - ./$THEME_FILE" - exit 1 - fi - cp "$source_file" "$MASTER_THEME_PATH" - chmod 644 "$MASTER_THEME_PATH" - print_success "Copied theme to master location" - fi -} - -get_users_with_tty() { - local users=() - [[ -d "/root/.oh-my-zsh" ]] && users+=("root") - - while IFS=: read -r username _ uid _ _ home_dir _; do - [[ $uid -lt 1000 ]] && continue - [[ -d "$home_dir/.oh-my-zsh" ]] && users+=("$username") - done < /etc/passwd - - echo "${users[@]}" -} - -get_current_user() { - if [[ -n "${SUDO_USER:-}" ]]; then - echo "$SUDO_USER" - else - while IFS=: read -r username _ uid _ _ home_dir _; do - if [[ $uid -ge 1000 ]] && [[ -d "$home_dir/.oh-my-zsh" ]]; then - echo "$username" - return - fi - done < /etc/passwd - fi -} - -select_users() { - local mode="$1" - local users=() - - case "$mode" in - all) - users=($(get_users_with_tty)) - ;; - current) - local current_user=$(get_current_user) - [[ -n "$current_user" ]] && users=("$current_user") - [[ -d "/root/.oh-my-zsh" ]] && users+=("root") - ;; - interactive) - local all_users=($(get_users_with_tty)) - [[ ${#all_users[@]} -eq 0 ]] && { print_error "No users with oh-my-zsh found"; exit 1; } - - echo "Users with oh-my-zsh:" - for i in "${!all_users[@]}"; do - echo " $((i+1)). ${all_users[$i]}" - done - echo - - if ask_yes_no "Deploy to all users?"; then - users=("${all_users[@]}") - else - local current_user=$(get_current_user) - [[ -n "$current_user" ]] && users=("$current_user") && print_info "Selected: $current_user" - [[ -d "/root/.oh-my-zsh" ]] && ask_yes_no "Include root?" && users+=("root") - fi - ;; - esac - - echo "${users[@]}" -} - -deploy_for_user() { - local username="$1" - local home_dir=$([[ "$username" == "root" ]] && echo "/root" || eval echo "~$username") - - [[ ! -d "$home_dir" ]] && { print_warning "Home not found: $username"; return 1; } - [[ ! -d "$home_dir/.oh-my-zsh" ]] && { print_warning "oh-my-zsh not installed: $username"; return 1; } - - local theme_link="$home_dir/.oh-my-zsh/themes/$THEME_FILE" - local status=$(get_link_status "$theme_link") - - case "$status" in - system_link) - [[ "$FORCE_REPLACE" != true ]] && { print_success "Already system-wide: $username"; return 0; } - print_info "Recreating link: $username" - ;; - local_link) print_info "Converting local → system: $username" ;; - regular_file) print_warning "Replacing file → system: $username" ;; - *) print_info "Creating link: $username" ;; - esac - - mkdir -p "$home_dir/.oh-my-zsh/themes" - rm -f "$theme_link" - ln -sf "$MASTER_THEME_PATH" "$theme_link" - - [[ "$username" != "root" ]] && chown -h "$username:$(id -gn "$username" 2>/dev/null || echo "$username")" "$theme_link" 2>/dev/null || true - - is_system_symlink "$theme_link" && print_success "Deployed: $username" || { print_error "Failed: $username"; return 1; } -} - -show_deployment_status() { - print_step "Deployment status" - - local users=($(get_users_with_tty)) - [[ ${#users[@]} -eq 0 ]] && { print_warning "No users with oh-my-zsh"; return; } - - echo - printf "%-20s %-20s %s\n" "User" "Status" "Details" - printf "%-20s %-20s %s\n" "----" "------" "-------" - - for user in "${users[@]}"; do - local home_dir=$([[ "$user" == "root" ]] && echo "/root" || eval echo "~$user") - local theme_path="$home_dir/.oh-my-zsh/themes/$THEME_FILE" - local status=$(get_link_status "$theme_path") - - case "$status" in - system_link) printf "%-20s ${GREEN}%-20s${NC} %s\n" "$user" "System-wide ✓" "→ $MASTER_THEME_PATH" ;; - local_link) printf "%-20s ${YELLOW}%-20s${NC} %s\n" "$user" "Local symlink" "→ $(readlink "$theme_path")" ;; - regular_file) printf "%-20s ${CYAN}%-20s${NC} %s\n" "$user" "Regular file" "(standalone)" ;; - not_present) printf "%-20s ${RED}%-20s${NC}\n" "$user" "Not installed" ;; - *) printf "%-20s ${RED}%-20s${NC}\n" "$user" "Unknown" ;; - esac - done - echo -} - -show_summary() { - echo - echo "============================================================================" - echo "Master theme: $MASTER_THEME_PATH" - echo - echo "To update theme globally:" - echo " sudo cp $SOURCE_THEME $MASTER_THEME_PATH" - echo - echo "Check status: sudo $0 --status" - echo "============================================================================" -} - -# ============================================================================ -# Main -# ============================================================================ - -main() { - local mode="interactive" - local status_only=false - - for arg in "$@"; do - case "$arg" in - --all) mode="all" ;; - --current) mode="current" ;; - --force) FORCE_REPLACE=true ;; - --status|-s) status_only=true ;; - --help|-h) - echo "Usage: sudo $0 [OPTIONS]" - echo - echo "Options:" - echo " --all Deploy to all users with oh-my-zsh" - echo " --current Deploy to current user and root" - echo " --force Force replacement of existing links" - echo " --status Show current deployment status" - echo " --help Show this help" - exit 0 - ;; - *) print_error "Unknown option: $arg"; exit 1 ;; - esac - done - - print_header - check_root - - if [[ "$status_only" == true ]]; then - show_deployment_status - exit 0 - fi - - show_deployment_status - setup_master_location - - local users=($(select_users "$mode")) - [[ ${#users[@]} -eq 0 ]] && { print_error "No users selected"; exit 1; } - - print_step "Deploying to ${#users[@]} user(s): ${users[*]}" - [[ "$FORCE_REPLACE" == true ]] && print_warning "Force mode enabled" - - ask_yes_no "Proceed?" || { print_warning "Cancelled"; exit 0; } - - echo - local ok=0 fail=0 - for user in "${users[@]}"; do - deploy_for_user "$user" && ((ok++)) || ((fail++)) - done - - echo - [[ $fail -eq 0 ]] && print_success "Complete! ($ok/${#users[@]})" || print_warning "Done with errors ($ok ok, $fail failed)" - - show_deployment_status - show_summary -} - -main "$@" diff --git a/bin/shell-stats.sh b/bin/dotfile-stats.sh similarity index 100% rename from bin/shell-stats.sh rename to bin/dotfile-stats.sh diff --git a/bin/vault.sh b/bin/dotfiles-vault.sh similarity index 100% rename from bin/vault.sh rename to bin/dotfiles-vault.sh diff --git a/bin/update-dotfiles.sh b/bin/dotfiles.update.sh similarity index 100% rename from bin/update-dotfiles.sh rename to bin/dotfiles.update.sh diff --git a/docs/SETUP_GUIDE.md b/docs/SETUP_GUIDE.md index 11b2327..544d1a3 100644 --- a/docs/SETUP_GUIDE.md +++ b/docs/SETUP_GUIDE.md @@ -254,14 +254,20 @@ fuck # Re-run last command with typo fixed ### Shell Analytics ```bash -shell-stats.sh # Full dashboard -shell-stats.sh --top 20 # Top 20 commands -shell-stats.sh --suggest # Alias recommendations -shell-stats.sh --heatmap # Activity by hour -shell-stats.sh --dirs # Most visited directories -shell-stats.sh --git # Git command breakdown -shell-stats.sh --docker # Docker command breakdown -shell-stats.sh --export # Export as JSON +dotfiles-stats.sh # Full dashboard +dotfiles-stats.sh --top 20 # Top 20 commands +dotfiles-stats.sh --suggest # Alias recommendations +dotfiles-stats.sh --heatmap # Activity by hour +dotfiles-stats.sh --dirs # Most visited directories +dotfiles-stats.sh --git # Git command breakdown +dotfiles-stats.sh --docker # Docker command breakdown +dotfiles-stats.sh --export # Export as JSON + +# Aliases +dfstats # Full dashboard +stats # Full dashboard +tophist # Top commands +suggest # Alias suggestions ``` ### Secrets Vault @@ -269,14 +275,22 @@ shell-stats.sh --export # Export as JSON Encrypted storage using `age` or `gpg`: ```bash -vault set KEY "value" # Store (or prompt for value) -vault get KEY # Retrieve -vault list # Show all keys -vault delete KEY # Remove -vault shell # Print as export statements -vault export backup.enc # Backup encrypted vault -vault import backup.enc # Restore vault -vault status # Show vault info +dotfiles-vault.sh set KEY "value" # Store (or prompt for value) +dotfiles-vault.sh get KEY # Retrieve +dotfiles-vault.sh list # Show all keys +dotfiles-vault.sh delete KEY # Remove +dotfiles-vault.sh shell # Print as export statements +dotfiles-vault.sh export backup.enc # Backup encrypted vault +dotfiles-vault.sh import backup.enc # Restore vault +dotfiles-vault.sh status # Show vault info + +# Aliases (defined in aliases.zsh) +vault set KEY "value" +vault get KEY +vault list +vls # vault list +vget KEY # vault get +vset KEY # vault set ``` **Auto-loading:** Secrets are automatically loaded into your environment on shell start. @@ -291,6 +305,13 @@ dotfiles-sync.sh --pull # Pull remote changes dotfiles-sync.sh --diff # Show local changes dotfiles-sync.sh --watch 300 # Auto-sync every 5 minutes dotfiles-sync.sh --log # Show sync history + +# Aliases +dfs # Interactive sync +dfsync # Interactive sync +dfpush # Push changes +dfpull # Pull changes +dfstatus # Show status ``` **Auto-check:** On shell start, you'll be notified of available updates. @@ -380,6 +401,63 @@ motd # Alias for show_motd --- +## Command Aliases + +All dotfiles commands have convenient aliases defined in `~/.dotfiles/zsh/aliases.zsh`: + +### Core Commands + +| Alias | Full Command | Description | +|-------|--------------|-------------| +| `dotfiles` / `df` | `cd ~/.dotfiles` | Go to dotfiles directory | +| `dfd` / `doctor` | `dotfiles-doctor.sh` | Run health check | +| `dffix` | `dotfiles-doctor.sh --fix` | Auto-fix issues | +| `dfs` / `dfsync` | `dotfiles-sync.sh` | Interactive sync | +| `dfpush` | `dotfiles-sync.sh --push` | Push local changes | +| `dfpull` | `dotfiles-sync.sh --pull` | Pull remote changes | +| `dfstatus` | `dotfiles-sync.sh --status` | Show sync status | +| `dfu` / `dfupdate` | `dotfiles-update.sh` | Update dotfiles | +| `dfv` / `dfversion` | `dotfiles-version.sh` | Show version | +| `dfstats` / `stats` | `dotfiles-stats.sh` | Shell analytics | +| `tophist` | `dotfiles-stats.sh --top` | Top commands | +| `suggest` | `dotfiles-stats.sh --suggest` | Alias suggestions | + +### Vault Commands + +| Alias | Full Command | Description | +|-------|--------------|-------------| +| `vault` | `dotfiles-vault.sh` | Vault CLI | +| `vls` | `dotfiles-vault.sh list` | List secrets | +| `vget` | `dotfiles-vault.sh get` | Get secret | +| `vset` | `dotfiles-vault.sh set` | Set secret | + +### Quick Edit + +| Alias | Description | +|-------|-------------| +| `zshrc` | Edit ~/.zshrc | +| `dfconf` | Edit dotfiles.conf | +| `dfedit` | Open dotfiles in editor | +| `reload` / `rl` | Reload shell config | + +### CLI Wrapper + +The `dotfiles-cli` (alias: `dfc`) provides a unified interface: + +```bash +dfc doctor # Run health check +dfc sync # Sync dotfiles +dfc update # Update dotfiles +dfc version # Show version +dfc stats # Shell analytics +dfc vault # Secrets manager +dfc edit # Open in editor +dfc cd # Go to dotfiles dir +dfc help # Show help +``` + +--- + ## Customization ### Adding Aliases @@ -596,7 +674,42 @@ chsh -s /bin/bash | `~/.dotfiles/vim/.vimrc` | `~/.vimrc` | | `~/.dotfiles/tmux/.tmux.conf` | `~/.tmux.conf` | | `~/.dotfiles/espanso/` | `~/.config/espanso` | -| `~/.dotfiles/bin/*` | `~/.local/bin/*` | +| `~/.dotfiles/bin/dotfiles-*.sh` | `~/.local/bin/dotfiles-*.sh` | + +### Directory Structure + +``` +~/.dotfiles/ +├── bin/ # Core scripts (symlinked to ~/.local/bin) +│ ├── dotfiles-doctor.sh +│ ├── dotfiles-stats.sh +│ ├── dotfiles-sync.sh +│ ├── dotfiles-update.sh +│ ├── dotfiles-vault.sh +│ └── dotfiles-version.sh +├── setup/ # Setup scripts (not symlinked) +│ ├── setup-wizard.sh +│ └── setup-espanso.sh +├── zsh/ +│ ├── .zshrc +│ ├── aliases.zsh # Dotfiles command aliases +│ ├── themes/ +│ │ └── adlee.zsh-theme +│ └── functions/ +│ ├── command-palette.zsh +│ ├── motd.zsh +│ ├── password-manager.zsh +│ ├── smart-suggest.zsh +│ └── snapper.zsh +├── espanso/ +│ └── match/ +│ ├── base.yml +│ └── personal.yml +├── vault/ # Encrypted secrets (gitignored) +├── docs/ +├── dotfiles.conf +└── install.sh +``` ### Key Files @@ -604,9 +717,12 @@ chsh -s /bin/bash |------|---------| | `dotfiles.conf` | Central configuration | | `zsh/.zshrc` | Main shell config | +| `zsh/aliases.zsh` | Command aliases | | `zsh/themes/adlee.zsh-theme` | Prompt theme | | `zsh/functions/smart-suggest.zsh` | Typo correction | | `zsh/functions/command-palette.zsh` | Fuzzy launcher | +| `zsh/functions/motd.zsh` | Dynamic MOTD | +| `zsh/functions/password-manager.zsh` | Password manager integration | | `espanso/match/base.yml` | Text expansion snippets | | `espanso/match/personal.yml` | Personal snippets | | `vault/` | Encrypted secrets (gitignored) | diff --git a/install.sh b/install.sh index e7960b6..ee0d892 100755 --- a/install.sh +++ b/install.sh @@ -697,6 +697,98 @@ install_optional_tools() { fi } +install_password_managers() { + print_step "Password manager CLI tools" + + # 1Password CLI + if ! command -v op &> /dev/null; then + if should_install "$INSTALL_1PASSWORD" "1Password CLI (op)"; then + case "$OS" in + ubuntu|debian) + curl -sS https://downloads.1password.com/linux/keys/1password.asc | sudo gpg --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/$(dpkg --print-architecture) stable main" | sudo tee /etc/apt/sources.list.d/1password.list + sudo apt update && sudo apt install -y 1password-cli + ;; + fedora|rhel|centos) + sudo rpm --import https://downloads.1password.com/linux/keys/1password.asc + sudo sh -c 'echo -e "[1password]\nname=1Password Stable Channel\nbaseurl=https://downloads.1password.com/linux/rpm/stable/\$basearch\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://downloads.1password.com/linux/keys/1password.asc" > /etc/yum.repos.d/1password.repo' + sudo dnf install -y 1password-cli + ;; + arch|cachyos) + if command -v paru &>/dev/null; then + paru -S --noconfirm 1password-cli + elif command -v yay &>/dev/null; then + yay -S --noconfirm 1password-cli + else + print_warning "Install 1password-cli from AUR manually" + fi + ;; + macos) + brew install --cask 1password-cli + ;; + esac + command -v op &>/dev/null && print_success "1Password CLI installed" + fi + else + print_success "1Password CLI already installed" + fi + + # LastPass CLI + if ! command -v lpass &> /dev/null; then + if should_install "$INSTALL_LASTPASS" "LastPass CLI (lpass)"; then + case "$OS" in + ubuntu|debian) + sudo apt-get install -y lastpass-cli + ;; + fedora|rhel|centos) + sudo dnf install -y lastpass-cli + ;; + arch|cachyos) + sudo pacman -S --noconfirm lastpass-cli + ;; + macos) + brew install lastpass-cli + ;; + esac + command -v lpass &>/dev/null && print_success "LastPass CLI installed" + fi + else + print_success "LastPass CLI already installed" + fi + + # Bitwarden CLI + if ! command -v bw &> /dev/null; then + if should_install "$INSTALL_BITWARDEN" "Bitwarden CLI (bw)"; then + case "$OS" in + ubuntu|debian|fedora|rhel|centos) + if command -v npm &>/dev/null; then + sudo npm install -g @bitwarden/cli + else + print_warning "Bitwarden CLI requires npm. Install Node.js first." + fi + ;; + arch|cachyos) + if command -v paru &>/dev/null; then + paru -S --noconfirm bitwarden-cli + elif command -v yay &>/dev/null; then + yay -S --noconfirm bitwarden-cli + else + sudo pacman -S --noconfirm bitwarden-cli 2>/dev/null || { + [[ -x "$(command -v npm)" ]] && sudo npm install -g @bitwarden/cli + } + fi + ;; + macos) + brew install bitwarden-cli + ;; + esac + command -v bw &>/dev/null && print_success "Bitwarden CLI installed" + fi + else + print_success "Bitwarden CLI already installed" + fi +} + # ============================================================================ # Main # ============================================================================ @@ -736,6 +828,7 @@ main() { link_espanso_config set_zsh_default install_optional_tools + install_password_managers echo print_success "Installation complete!" @@ -744,10 +837,14 @@ main() { echo " 1. Restart your terminal or run: exec zsh" echo " 2. Your old configs are backed up in: $BACKUP_DIR" echo " 3. Customize settings in: $DOTFILES_DIR/dotfiles.conf" - echo " 4. Run 'dotfiles-doctor.sh' to verify installation" + echo " 4. Run 'dfd' or 'dotfiles-doctor.sh' to verify installation" echo - echo -e "${BLUE}To update dotfiles in the future:${NC}" - echo " cd ~/.dotfiles && git pull && ./install.sh" + echo -e "${BLUE}Useful commands:${NC}" + echo " dfd / doctor - Health check" + echo " dfs / dfsync - Sync dotfiles" + echo " dfu / dfupdate - Update dotfiles" + echo " dfstats / stats - Shell analytics" + echo " vault - Secrets manager" echo echo -e "${BLUE}To uninstall:${NC}" echo " ./install.sh --uninstall" diff --git a/bin/setup-espanso.sh b/setup/setup-espanso.sh similarity index 100% rename from bin/setup-espanso.sh rename to setup/setup-espanso.sh diff --git a/bin/setup-wizard.sh b/setup/setup-wizard.sh similarity index 100% rename from bin/setup-wizard.sh rename to setup/setup-wizard.sh diff --git a/zsh/.zshrc b/zsh/.zshrc index bcb1155..9eb7140 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -110,12 +110,14 @@ alias di='docker images' alias dex='docker exec -it' # System shortcuts -alias reload='source ~/.zshrc' -alias zshconfig='vim ~/.zshrc' -alias themeconfig='vim ~/.oh-my-zsh/themes/adlee.zsh-theme' alias h='history' alias c='clear' +# --- Source Dotfiles Aliases --- +if [[ -f "$HOME/.dotfiles/zsh/aliases.zsh" ]]; then + source "$HOME/.dotfiles/zsh/aliases.zsh" +fi + # Safe operations alias rm='rm -i' alias cp='cp -i' @@ -325,8 +327,8 @@ fi # --- Vault Integration --- # Source vault secrets into environment (if vault exists and has secrets) -if command -v vault.sh &>/dev/null && [[ -f "$HOME/.dotfiles/vault/secrets.enc" ]]; then - eval "$(vault.sh shell 2>/dev/null)" || true +if command -v dotfiles-vault.sh &>/dev/null && [[ -f "$HOME/.dotfiles/vault/secrets.enc" ]]; then + eval "$(dotfiles-vault.sh shell 2>/dev/null)" || true fi # --- Password Manager Integration --- diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh new file mode 100644 index 0000000..7d9441e --- /dev/null +++ b/zsh/aliases.zsh @@ -0,0 +1,91 @@ +# ============================================================================ +# Dotfiles Command Aliases +# ============================================================================ +# Convenient shortcuts for dotfiles management scripts +# +# Source this file in .zshrc (already included by default) +# ============================================================================ + +# --- Core Dotfiles Commands --- +alias dotfiles='cd ~/.dotfiles' +alias df='cd ~/.dotfiles' + +# Doctor - health check +alias dfd='dotfiles-doctor.sh' +alias doctor='dotfiles-doctor.sh' +alias dffix='dotfiles-doctor.sh --fix' + +# Sync - multi-machine synchronization +alias dfs='dotfiles-sync.sh' +alias dfsync='dotfiles-sync.sh' +alias dfpush='dotfiles-sync.sh --push' +alias dfpull='dotfiles-sync.sh --pull' +alias dfstatus='dotfiles-sync.sh --status' + +# Update - pull latest and reinstall +alias dfu='dotfiles-update.sh' +alias dfupdate='dotfiles-update.sh' + +# Version - check version info +alias dfv='dotfiles-version.sh' +alias dfversion='dotfiles-version.sh' + +# Stats - shell analytics +alias dfstats='dotfiles-stats.sh' +alias stats='dotfiles-stats.sh' +alias tophist='dotfiles-stats.sh --top' +alias suggest='dotfiles-stats.sh --suggest' + +# Vault - secrets management +alias vault='dotfiles-vault.sh' +alias vls='dotfiles-vault.sh list' +alias vget='dotfiles-vault.sh get' +alias vset='dotfiles-vault.sh set' + +# --- Quick Edit Aliases --- +alias zshrc='${EDITOR:-vim} ~/.zshrc' +alias dfconf='${EDITOR:-vim} ~/.dotfiles/dotfiles.conf' +alias dfedit='cd ~/.dotfiles && ${EDITOR:-vim} .' + +# --- Reload Aliases --- +alias reload='source ~/.zshrc' +alias rl='source ~/.zshrc' + +# ============================================================================ +# Function Wrappers (for tab completion) +# ============================================================================ + +# Dotfiles main command with subcommands +dotfiles-cli() { + case "${1:-help}" in + doctor|doc|d) shift; dotfiles-doctor.sh "$@" ;; + sync|s) shift; dotfiles-sync.sh "$@" ;; + update|up|u) shift; dotfiles-update.sh "$@" ;; + version|ver|v) shift; dotfiles-version.sh "$@" ;; + stats|st) shift; dotfiles-stats.sh "$@" ;; + vault|vlt) shift; dotfiles-vault.sh "$@" ;; + edit|e) cd ~/.dotfiles && ${EDITOR:-vim} . ;; + cd) cd ~/.dotfiles ;; + help|--help|-h|*) + echo "Dotfiles CLI" + echo + echo "Usage: dotfiles-cli [args]" + echo + echo "Commands:" + echo " doctor, d Run health check (--fix to auto-repair)" + echo " sync, s Sync dotfiles across machines" + echo " update, u Pull latest and reinstall" + echo " version, v Show version info" + echo " stats, st Shell analytics dashboard" + echo " vault, vlt Secrets management" + echo " edit, e Open dotfiles in editor" + echo " cd Change to dotfiles directory" + echo + echo "Aliases:" + echo " dfd, dffix, dfs, dfpush, dfpull, dfu, dfv, dfstats, vault" + ;; + esac +} + +# Short alias for the CLI +alias dfc='dotfiles-cli' diff --git a/zsh/temp b/zsh/temp deleted file mode 100755 index 1fca4dd..0000000 --- a/zsh/temp +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions -git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting - -