mirror of
https://github.com/SeriousBug/dotfiles
synced 2025-12-06 21:12:08 -06:00
Add interactive Dotter configuration to setup script
Implements user variable prompting (git name/email) with persistence to .dotter/user_vars.sh. Only prompts for missing variables on subsequent runs. Adds --reset flag to reconfigure all variables. Auto-generates local.toml and deploys dotfiles automatically. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
164013420c
commit
989fab7a18
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,3 +2,4 @@
|
|||
.dotter/local.toml
|
||||
.dotter/cache.toml
|
||||
.dotter/cache/
|
||||
.dotter/user_vars.sh
|
||||
|
|
|
|||
86
setup.sh
86
setup.sh
|
|
@ -2,6 +2,13 @@
|
|||
|
||||
set -e
|
||||
|
||||
# Parse command line arguments
|
||||
RESET_CONFIG=false
|
||||
if [[ "$1" == "--reset" ]]; then
|
||||
RESET_CONFIG=true
|
||||
echo "Resetting configuration (will re-prompt for all variables)..."
|
||||
fi
|
||||
|
||||
echo "Setting up dotfiles environment..."
|
||||
|
||||
# Detect OS
|
||||
|
|
@ -81,8 +88,83 @@ if command -v gh &> /dev/null; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Configure Dotter
|
||||
echo ""
|
||||
echo "Configuring Dotter..."
|
||||
|
||||
# Path to user variables file
|
||||
USER_VARS_FILE=".dotter/user_vars.sh"
|
||||
|
||||
# Source existing variables if not resetting
|
||||
if [[ "$RESET_CONFIG" == false && -f "$USER_VARS_FILE" ]]; then
|
||||
echo "Loading existing configuration..."
|
||||
source "$USER_VARS_FILE"
|
||||
fi
|
||||
|
||||
# Prompt for missing variables
|
||||
if [[ -z "$GIT_NAME" ]]; then
|
||||
read -p "Enter your Git user name: " GIT_NAME
|
||||
fi
|
||||
|
||||
if [[ -z "$GIT_EMAIL" ]]; then
|
||||
read -p "Enter your Git email: " GIT_EMAIL
|
||||
fi
|
||||
|
||||
# Detect Homebrew path if not set
|
||||
if [[ -z "$BREW_PATH" ]]; then
|
||||
if [[ "$OS" == "Darwin" ]]; then
|
||||
if [[ -d "/opt/homebrew" ]]; then
|
||||
BREW_PATH="/opt/homebrew"
|
||||
else
|
||||
BREW_PATH="/usr/local"
|
||||
fi
|
||||
else
|
||||
BREW_PATH="/home/linuxbrew/.linuxbrew"
|
||||
fi
|
||||
echo "Detected Homebrew path: $BREW_PATH"
|
||||
fi
|
||||
|
||||
# Save variables to file
|
||||
echo "Saving configuration..."
|
||||
cat > "$USER_VARS_FILE" << EOF
|
||||
# Dotter user variables
|
||||
# This file is sourced by setup.sh to avoid re-prompting for values
|
||||
# To reset and re-prompt for all values, run: ./setup.sh --reset
|
||||
|
||||
GIT_NAME="$GIT_NAME"
|
||||
GIT_EMAIL="$GIT_EMAIL"
|
||||
BREW_PATH="$BREW_PATH"
|
||||
EOF
|
||||
|
||||
# Generate local.toml
|
||||
echo "Generating Dotter configuration..."
|
||||
cat > .dotter/local.toml << EOF
|
||||
# Machine-specific Dotter configuration
|
||||
# This file is generated by setup.sh
|
||||
|
||||
packages = ["git", "nvim", "fish", "zellij", "htop", "asdf"]
|
||||
|
||||
[variables]
|
||||
git_name = "$GIT_NAME"
|
||||
git_email = "$GIT_EMAIL"
|
||||
brew_path = "$BREW_PATH"
|
||||
EOF
|
||||
|
||||
# Deploy dotfiles
|
||||
echo ""
|
||||
echo "Deploying dotfiles..."
|
||||
if dotter deploy -v; then
|
||||
echo "✓ Dotfiles deployed successfully!"
|
||||
else
|
||||
echo "⚠ Dotter deployment failed. You may need to run 'dotter deploy -f' to force deployment."
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✓ Setup complete!"
|
||||
echo ""
|
||||
echo "Configuration saved to: $USER_VARS_FILE"
|
||||
echo "To reconfigure, run: ./setup.sh --reset"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Run 'dotter deploy' to deploy your dotfiles"
|
||||
echo " 2. Consider setting fish as your default shell: chsh -s \$(which fish)"
|
||||
echo " 1. Consider setting fish as your default shell: chsh -s \$(which fish)"
|
||||
echo " 2. Restart your terminal or source your new shell configuration"
|
||||
|
|
|
|||
Loading…
Reference in a new issue