diff --git a/dotfiles.sh b/dotfiles.sh new file mode 100644 index 0000000..2058c0d --- /dev/null +++ b/dotfiles.sh @@ -0,0 +1,54 @@ +cd ~.dotfiles +git pull +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!" \ No newline at end of file diff --git a/setup.sh b/setup.sh index 04e7f53..b32f24e 100755 --- a/setup.sh +++ b/setup.sh @@ -90,4 +90,5 @@ create_symlinks "$HOME/.dotfiles" "$HOME" echo "Dotfiles setup complete!" -# Install fonts \ No newline at end of file +# Install scripts +git clone git@woodburn.au:nathanwoodburn/scripts.git ~/scripts \ No newline at end of file