feat: Add more setup

This commit is contained in:
Nathan Woodburn 2025-03-28 14:06:01 +11:00
parent d1b33bde8e
commit fbaabcae6e
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 56 additions and 1 deletions

54
dotfiles.sh Normal file
View File

@ -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!"

View File

@ -90,4 +90,5 @@ create_symlinks "$HOME/.dotfiles" "$HOME"
echo "Dotfiles setup complete!"
# Install fonts
# Install scripts
git clone git@woodburn.au:nathanwoodburn/scripts.git ~/scripts