feat: Update setup to correctly copy dotfiles

This commit is contained in:
Nathan Woodburn 2025-03-28 14:13:31 +11:00
parent 15cc10f547
commit acf133adca
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 27 additions and 75 deletions

View File

@ -24,25 +24,6 @@ create_symlinks() {
echo "Linking directory: $src_dir/.zsh_functions -> $target_zsh_functions"
ln -s "$src_dir/.zsh_functions" "$target_zsh_functions"
fi
# Handle .config/alacritty/themes directory specially - link the whole directory
if [ -d "$src_dir/.config/alacritty/themes" ]; then
local target_alacritty_themes="$target_dir/.config/alacritty/themes"
# Remove existing directory or symlink if it exists
if [ -e "$target_alacritty_themes" ] || [ -L "$target_alacritty_themes" ]; then
echo "Removing existing: $target_alacritty_themes"
rm -rf "$target_alacritty_themes"
fi
# Ensure .config/alacritty directory exists
mkdir -p "$target_dir/.config/alacritty"
# Create symlink for the entire directory
echo "Linking directory: $src_dir/.config/alacritty/themes -> $target_alacritty_themes"
ln -s "$src_dir/.config/alacritty/themes" "$target_alacritty_themes"
fi
# Find all files and directories in the source directory, excluding .git, README.md, and .zsh_functions
find "$src_dir" \( -not -path "*/\.git*" -and -not -name "README.md" -and -not -path "*/.zsh_functions/*" -and -not -path "*/.zsh_functions" \) -and \( -type f -o -type l \) | while read -r src_file; do
@ -65,8 +46,33 @@ create_symlinks() {
echo "Linking: $src_file -> $target_file"
ln -s "$src_file" "$target_file"
done
# Handle .config/alacritty/themes directory specially - link the whole directory
if [ -d "$src_dir/.config/alacritty/themes" ]; then
local target_alacritty_themes="$target_dir/.config/alacritty/themes"
# Remove existing directory or symlink if it exists
if [ -e "$target_alacritty_themes" ] || [ -L "$target_alacritty_themes" ]; then
echo "Removing existing: $target_alacritty_themes"
rm -rf "$target_alacritty_themes"
fi
# Ensure .config/alacritty directory exists
mkdir -p "$target_dir/.config/alacritty"
# Make sure to pull latest changes from the repo submodules
git submodule update --init --recursive
# Create symlink for the entire directory
echo "Linking directory: $src_dir/.config/alacritty/themes -> $target_alacritty_themes"
ln -s "$src_dir/.config/alacritty/themes" "$target_alacritty_themes"
fi
}
# Call the function to create symlinks from dotfiles to home
create_symlinks "$HOME/.dotfiles" "$HOME"

View File

@ -33,62 +33,8 @@ sudo update-desktop-database
# Install dotfiles
git clone git@woodburn.au:nathanwoodburn/dotfiles.git ~/.dotfiles
cd ~/.dotfiles
# All files are in the dotfiles directory or a subdirectory
# Create symbolic links for all dotfiles
echo "Creating symbolic links for dotfiles..."
# Function to create symlinks recursively
create_symlinks() {
local src_dir="$1"
local target_dir="$2"
# Create the target directory if it doesn't exist
mkdir -p "$target_dir"
# Handle .zsh_functions directory specially - link the whole directory
if [ -d "$src_dir/.zsh_functions" ]; then
local target_zsh_functions="$target_dir/.zsh_functions"
# Remove existing directory or symlink if it exists
if [ -e "$target_zsh_functions" ] || [ -L "$target_zsh_functions" ]; then
echo "Removing existing: $target_zsh_functions"
rm -rf "$target_zsh_functions"
fi
# Create symlink for the entire directory
echo "Linking directory: $src_dir/.zsh_functions -> $target_zsh_functions"
ln -s "$src_dir/.zsh_functions" "$target_zsh_functions"
fi
# Find all files and directories in the source directory, excluding .git, README.md, and .zsh_functions
find "$src_dir" \( -not -path "*/\.git*" -and -not -name "README.md" -and -not -path "*/.zsh_functions/*" -and -not -path "*/.zsh_functions" \) -and \( -type f -o -type l \) | while read -r src_file; do
# Get the relative path from src_dir
rel_path="${src_file#$src_dir/}"
# Construct the target file path
target_file="$target_dir/$rel_path"
# Create parent directories if they don't exist
mkdir -p "$(dirname "$target_file")"
# Remove existing file if it exists
if [ -e "$target_file" ] || [ -L "$target_file" ]; then
echo "Removing existing file: $target_file"
rm -f "$target_file"
fi
# Create symlink
echo "Linking: $src_file -> $target_file"
ln -s "$src_file" "$target_file"
done
}
# Call the function to create symlinks from dotfiles to home
create_symlinks "$HOME/.dotfiles" "$HOME"
echo "Dotfiles setup complete!"
# Run dotfiles setup
./dotfiles.sh
# Install scripts
git clone git@woodburn.au:nathanwoodburn/scripts.git ~/scripts