From acf133adca9b65e171cd6fc989e46f30f7f19553 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn <github@nathan.woodburn.au> Date: Fri, 28 Mar 2025 14:13:31 +1100 Subject: [PATCH] feat: Update setup to correctly copy dotfiles --- dotfiles.sh | 44 ++++++++++++++++++++++------------------ setup.sh | 58 ++--------------------------------------------------- 2 files changed, 27 insertions(+), 75 deletions(-) diff --git a/dotfiles.sh b/dotfiles.sh index 7471994..2775448 100755 --- a/dotfiles.sh +++ b/dotfiles.sh @@ -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" diff --git a/setup.sh b/setup.sh index b32f24e..13c005b 100755 --- a/setup.sh +++ b/setup.sh @@ -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 \ No newline at end of file