Dotfiles update 2025-12-26 19:59

This commit is contained in:
Aaron D. Lee
2025-12-26 19:59:25 -05:00
parent 91b7ec26d6
commit c08d276d94
9 changed files with 144 additions and 180 deletions

View File

@@ -133,19 +133,19 @@ print_header() {
local hostname="${HOSTNAME:-$(hostname -s 2>/dev/null)}"
local script_name="install.sh"
local datetime=$(date '+%a %b %d %H:%M')
# Colors
local _M_RESET=$'\033[0m'
local _M_BOLD=$'\033[1m'
local _M_DIM=$'\033[2m'
local _M_BLUE=$'\033[38;5;39m'
local _M_GREY=$'\033[38;5;242m'
# Build horizontal line
local hline=""
for ((i=0; i<_M_WIDTH; i++)); do hline+="═"; done
local inner=$((_M_WIDTH - 2))
# Header content
local h_left="${user}@${hostname}"
local h_center="${script_name}"
@@ -153,7 +153,7 @@ print_header() {
local h_pad=$(((inner - ${#h_left} - ${#h_center} - ${#h_right}) / 2))
local h_spaces=""
for ((i=0; i<h_pad; i++)); do h_spaces+=" "; done
echo ""
echo -e "${_M_GREY}${hline}${_M_RESET}"
echo -e "${_M_GREY}${_M_RESET} ${_M_BOLD}${_M_BLUE}${h_left}${_M_RESET}${h_spaces}${_M_DIM}${h_center}${h_spaces}${h_right}${_M_RESET} ${_M_GREY}${_M_RESET}"
@@ -232,7 +232,7 @@ detect_os() {
fi
source /etc/os-release
if [[ "$ID" != "arch" && "$ID" != "cachyos" ]]; then
print_error "This dotfiles is configured for Arch/CachyOS only"
print_error "Detected: $ID $VERSION_ID"
@@ -672,6 +672,15 @@ main() {
detect_os
# Run wizard if requested
if [[ "$RUN_WIZARD" == true ]]; then
run_wizard || {
print_warning "Wizard cancelled"
exit 0
}
echo ""
fi
# Handle --deps-only
if [[ "$DEPS_ONLY" == true ]]; then
install_dependencies
@@ -717,4 +726,127 @@ main() {
fi
}
# ============================================================================
# Interactive Configuration Wizard
# ============================================================================
run_wizard() {
clear
cat << 'EOF'
╔═══════════════════════════════════════════════════════════╗
║ ║
║ █████╗ ██████╗ ██╗ ███████╗███████╗ ║
║ ██╔══██╗██╔══██╗██║ ██╔════╝██╔════╝ ║
║ ███████║██║ ██║██║ █████╗ █████╗ ║
║ ██╔══██║██║ ██║██║ ██╔══╝ ██╔══╝ ║
║ ██║ ██║██████╔╝███████╗███████╗███████╗ ║
║ ╚═╝ ╚═╝╚═════╝ ╚══════╝╚══════╝╚══════╝ ║
║ ║
║ D O T F I L E S ║
║ Configuration Wizard ║
║ ║
╚═══════════════════════════════════════════════════════════╝
EOF
echo ""
echo "Let's set up your dotfiles configuration."
echo ""
# Personal Information
echo -e "${BLUE}Personal Information${NC}"
echo "────────────────────"
read -p "Full Name [${USER_FULLNAME:-}]: " wizard_name
wizard_name="${wizard_name:-$USER_FULLNAME}"
read -p "Email [${USER_EMAIL:-}]: " wizard_email
wizard_email="${wizard_email:-$USER_EMAIL}"
read -p "GitHub Username [${USER_GITHUB:-}]: " wizard_github
wizard_github="${wizard_github:-$USER_GITHUB}"
echo ""
# Display Settings
echo -e "${BLUE}Display Settings${NC}"
echo "────────────────"
echo "MOTD (Message of the Day) Style:"
echo " 1) compact - Box with system info (recommended)"
echo " 2) mini - Single line"
echo " 3) full - Extended info"
echo " 4) none - Disable MOTD"
echo ""
read -p "Choice [1]: " motd_choice
case "${motd_choice:-1}" in
1) wizard_motd="compact" ;;
2) wizard_motd="mini" ;;
3) wizard_motd="full" ;;
4) wizard_motd="none" ;;
*) wizard_motd="compact" ;;
esac
echo ""
# Feature Toggles
echo -e "${BLUE}Features${NC}"
echo "────────"
if ask_yes_no "Enable smart command suggestions (typo correction)?"; then
wizard_suggestions="true"
else
wizard_suggestions="false"
fi
if ask_yes_no "Enable command palette (Ctrl+Space fuzzy launcher)?"; then
wizard_palette="true"
else
wizard_palette="false"
fi
echo ""
# Summary
echo -e "${BLUE}Configuration Summary${NC}"
echo "─────────────────────"
echo " Name: $wizard_name"
echo " Email: $wizard_email"
echo " GitHub: $wizard_github"
echo " MOTD Style: $wizard_motd"
echo " Smart Suggestions: $wizard_suggestions"
echo " Command Palette: $wizard_palette"
echo ""
if ! ask_yes_no "Save this configuration?"; then
echo "Configuration not saved."
return 1
fi
# Save to dotfiles.conf
local config_file="$DOTFILES_DIR/dotfiles.conf"
if [[ -f "$config_file" ]]; then
# Update existing values
sed -i "s/^USER_FULLNAME=.*/USER_FULLNAME=\"$wizard_name\"/" "$config_file"
sed -i "s/^USER_EMAIL=.*/USER_EMAIL=\"$wizard_email\"/" "$config_file"
sed -i "s/^USER_GITHUB=.*/USER_GITHUB=\"$wizard_github\"/" "$config_file"
sed -i "s/^MOTD_STYLE=.*/MOTD_STYLE=\"$wizard_motd\"/" "$config_file"
sed -i "s/^ENABLE_SMART_SUGGESTIONS=.*/ENABLE_SMART_SUGGESTIONS=\"$wizard_suggestions\"/" "$config_file"
sed -i "s/^ENABLE_COMMAND_PALETTE=.*/ENABLE_COMMAND_PALETTE=\"$wizard_palette\"/" "$config_file"
# Also update git config if not set
if [[ -z "$(grep '^GIT_USER_NAME=' "$config_file")" ]]; then
sed -i "s/^GIT_USER_NAME=.*/GIT_USER_NAME=\"$wizard_github\"/" "$config_file"
fi
if [[ -z "$(grep '^GIT_USER_EMAIL=' "$config_file")" ]]; then
sed -i "s/^GIT_USER_EMAIL=.*/GIT_USER_EMAIL=\"$wizard_email\"/" "$config_file"
fi
fi
echo ""
echo -e "${GREEN}${NC} Configuration saved!"
echo ""
# Reload the config
load_config
}
main "$@"

View File

@@ -1,175 +0,0 @@
#!/usr/bin/env bash
# ============================================================================
# Dotfiles Interactive Setup Wizard
# ============================================================================
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_RED=$'\033[0;31m'
DF_BLUE=$'\033[0;34m' DF_CYAN=$'\033[0;36m' DF_NC=$'\033[0m'
DF_BOLD=$'\033[1m' DF_DIM=$'\033[2m'
DOTFILES_HOME="${DOTFILES_HOME:-$HOME/.dotfiles}"
DOTFILES_VERSION="${DOTFILES_VERSION:-1.0.0}"
DF_WIDTH="${DF_WIDTH:-66}"
df_print_header() { echo "=== $1 ==="; }
df_print_success() { echo -e "${DF_GREEN}${DF_NC} $1"; }
}
# ============================================================================
# Gum Detection (for prettier TUI)
# ============================================================================
HAS_GUM=false
command -v gum &>/dev/null && HAS_GUM=true
wizard_confirm() {
local prompt="$1"
local default="${2:-yes}"
if [[ "$HAS_GUM" == true ]]; then
if [[ "$default" == "yes" ]]; then
gum confirm --default=yes "$prompt"
else
gum confirm --default=no "$prompt"
fi
else
local yn_prompt="[Y/n]"
[[ "$default" == "no" ]] && yn_prompt="[y/N]"
read -p "$prompt $yn_prompt: " response
response=${response:-${default:0:1}}
[[ "$response" =~ ^[Yy] ]]
fi
}
wizard_input() {
local prompt="$1"
local default="$2"
if [[ "$HAS_GUM" == true ]]; then
gum input --placeholder "$default" --value "$default" --prompt "$prompt: "
else
read -p "$prompt [$default]: " response
echo "${response:-$default}"
fi
}
wizard_choose() {
local prompt="$1"
shift
local options=("$@")
if [[ "$HAS_GUM" == true ]]; then
printf '%s\n' "${options[@]}" | gum choose --header "$prompt"
else
echo "$prompt"
local i=1
for opt in "${options[@]}"; do
echo " $i) $opt"
((i++))
done
read -p "Choice [1]: " choice
choice=${choice:-1}
echo "${options[$((choice-1))]}"
fi
}
# ============================================================================
# Wizard Steps
# ============================================================================
step_welcome() {
clear
df_print_header "setup-wizard"
echo -e "${DF_BOLD}Welcome to Dotfiles Setup Wizard${DF_NC}"
echo -e "${DF_DIM}Version: $DOTFILES_VERSION | Display Width: $DF_WIDTH${DF_NC}"
echo ""
wizard_confirm "Ready to begin?" || {
echo "Setup cancelled."
exit 0
}
}
step_user_info() {
echo ""
echo -e "${DF_BLUE}${DF_NC} Personal Information"
echo ""
USER_FULLNAME=$(wizard_input "Full Name" "${USER_FULLNAME:-}")
USER_EMAIL=$(wizard_input "Email" "${USER_EMAIL:-}")
USER_GITHUB=$(wizard_input "GitHub Username" "${USER_GITHUB:-}")
}
step_features() {
echo ""
echo -e "${DF_BLUE}${DF_NC} Feature Selection"
echo ""
MOTD_STYLE=$(wizard_choose "MOTD Style:" "compact" "mini" "full" "none")
wizard_confirm "Enable smart suggestions (typo correction)?" && ENABLE_SMART_SUGGESTIONS="true" || ENABLE_SMART_SUGGESTIONS="false"
wizard_confirm "Enable command palette (Ctrl+Space)?" && ENABLE_COMMAND_PALETTE="true" || ENABLE_COMMAND_PALETTE="false"
}
step_summary() {
echo ""
echo -e "${DF_GREEN}${DF_NC} Configuration Summary"
echo ""
echo " Name: $USER_FULLNAME"
echo " Email: $USER_EMAIL"
echo " GitHub: $USER_GITHUB"
echo " MOTD Style: $MOTD_STYLE"
echo " Smart Suggestions: $ENABLE_SMART_SUGGESTIONS"
echo " Command Palette: $ENABLE_COMMAND_PALETTE"
echo ""
if wizard_confirm "Save this configuration?"; then
save_config
df_print_success "Configuration saved!"
else
echo "Configuration not saved."
fi
}
save_config() {
local config_file="$DOTFILES_HOME/dotfiles.conf"
# Update values in config file
if [[ -f "$config_file" ]]; then
sed -i "s/^USER_FULLNAME=.*/USER_FULLNAME=\"$USER_FULLNAME\"/" "$config_file"
sed -i "s/^USER_EMAIL=.*/USER_EMAIL=\"$USER_EMAIL\"/" "$config_file"
sed -i "s/^USER_GITHUB=.*/USER_GITHUB=\"$USER_GITHUB\"/" "$config_file"
sed -i "s/^MOTD_STYLE=.*/MOTD_STYLE=\"$MOTD_STYLE\"/" "$config_file"
sed -i "s/^ENABLE_SMART_SUGGESTIONS=.*/ENABLE_SMART_SUGGESTIONS=\"$ENABLE_SMART_SUGGESTIONS\"/" "$config_file"
sed -i "s/^ENABLE_COMMAND_PALETTE=.*/ENABLE_COMMAND_PALETTE=\"$ENABLE_COMMAND_PALETTE\"/" "$config_file"
fi
}
step_next() {
echo ""
df_print_success "Setup Complete!"
echo ""
echo -e "${DF_DIM}Next steps:${DF_NC}"
echo " 1. Reload your shell: source ~/.zshrc"
echo " 2. Run health check: dfd"
echo " 3. Explore commands: dotfiles-cli help"
echo ""
}
# ============================================================================
# Main
# ============================================================================
main() {
step_welcome
step_user_info
step_features
step_summary
step_next
}
# Only run if executed directly (not sourced)
[[ "${BASH_SOURCE[0]}" == "${0}" ]] && main "$@"

View File

@@ -278,6 +278,13 @@ _deferred_load() {
# Setup FZF
_has_cmd fzf && _setup_fzf
# -----------------------------------------------------------------------
# Load machine-specific configuration
# This must be loaded early so machine configs can override other settings
# -----------------------------------------------------------------------
local machines_lib="$_dotfiles_dir/zsh/lib/machines.zsh"
[[ -f "$machines_lib" ]] && source "$machines_lib"
# -----------------------------------------------------------------------
# Load all function files from functions directory
# Excludes command-palette.zsh (already loaded) and motd.zsh (loaded separately)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.