1
0

feat: restructure dotfiles setup with bootstrap and setup scripts, enhance branch selection and backup processes

This commit is contained in:
2025-08-04 20:39:16 -05:00
parent 03150e539d
commit c366cd7789
9 changed files with 542 additions and 70 deletions

View File

@@ -12,17 +12,41 @@ backup_files() {
log_info "Checking for file conflicts..."
# Files that might conflict with stow
local files_to_check=(.bashrc .bash_aliases .inputrc .gitconfig)
local backed_up=()
for file in "${files_to_check[@]}"; do
if [ -f "$HOME/$file" ] && [ ! -L "$HOME/$file" ]; then
log_warning "Backing up existing file: $HOME/$file -> $HOME/${file}.bak"
mv "$HOME/$file" "$HOME/${file}.bak"
backed_up+=("$file")
fi
done
# Auto-discover files from stow directories
if [ -d "$dotfiles_dir/stow" ]; then
# Use new stow structure - scan all files in stow subdirectories
for config_dir in "$dotfiles_dir/stow"/*; do
if [ -d "$config_dir" ]; then
log_info "Checking $(basename "$config_dir") configuration for conflicts..."
# Find all files that would be stowed
find "$config_dir" -type f | while read -r file; do
# Get relative path from config directory
relative_file="${file#$config_dir/}"
target_file="$HOME/$relative_file"
if [ -f "$target_file" ] && [ ! -L "$target_file" ]; then
log_warning "Backing up existing file: $target_file -> ${target_file}.bak"
mv "$target_file" "${target_file}.bak"
backed_up+=("$relative_file")
fi
done
fi
done
else
# Fallback to old structure - hardcoded file list
local files_to_check=(.bashrc .bash_aliases .inputrc .gitconfig)
for file in "${files_to_check[@]}"; do
if [ -f "$HOME/$file" ] && [ ! -L "$HOME/$file" ]; then
log_warning "Backing up existing file: $HOME/$file -> $HOME/${file}.bak"
mv "$HOME/$file" "$HOME/${file}.bak"
backed_up+=("$file")
fi
done
fi
if [ ${#backed_up[@]} -gt 0 ]; then
log_info "Backed up ${#backed_up[@]} file(s): ${backed_up[*]}"