feat: Update dotfiles

This commit is contained in:
2025-03-28 16:17:38 +11:00
parent 755b457cc6
commit b31334a1c1
2 changed files with 47 additions and 63 deletions

View File

@@ -2,6 +2,9 @@ cd ~/.dotfiles
git pull git pull
echo "Creating symbolic links for dotfiles..." echo "Creating symbolic links for dotfiles..."
dirs_to_sym = (".config/alacritty/themes" ".zsh_functions")
sub_modules = (".config/alacritty/themes")
# Function to create symlinks recursively # Function to create symlinks recursively
create_symlinks() { create_symlinks() {
local src_dir="$1" local src_dir="$1"
@@ -9,64 +12,45 @@ create_symlinks() {
# Create the target directory if it doesn't exist # Create the target directory if it doesn't exist
mkdir -p "$target_dir" mkdir -p "$target_dir"
# For each file
# Handle .zsh_functions directory specially - link the whole directory for file in "$src_dir"/*; do
if [ -d "$src_dir/.zsh_functions" ]; then # Get the file name
local target_zsh_functions="$target_dir/.zsh_functions" local file_name=$(basename "$file")
# If the file is a directory
# Remove existing directory or symlink if it exists if [ -d "$file" ]; then
if [ -e "$target_zsh_functions" ] || [ -L "$target_zsh_functions" ]; then # Check if the directory is in the list of directories to symlink
echo "Removing existing: $target_zsh_functions" if [[ " ${dirs_to_sym[@]} " =~ " $file_name " ]]; then
rm -rf "$target_zsh_functions" # If the directory is in the list, create a symlink
echo "Linking directory: $file -> $target_dir/$file_name"
ln -s "$file" "$target_dir/$file_name"
else
# If the directory is not in the list, recursively call the function
create_symlinks "$file" "$target_dir/$file_name"
fi fi
else
# Create symlink for the entire directory # If the file is not a symlink
echo "Linking directory: $src_dir/.zsh_functions -> $target_zsh_functions" if [ ! -L "$target_dir/$file_name" ]; then
ln -s "$src_dir/.zsh_functions" "$target_zsh_functions" # If the file exists
if [ -e "$target_dir/$file_name" ]; then
# Remove the file
echo "Removing existing: $target_dir/$file_name"
rm -rf "$target_dir/$file_name"
fi
# Create a symlink
echo "Linking: $file -> $target_dir/$file_name"
ln -s "$file" "$target_dir/$file_name"
fi 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 fi
# Create symlink
echo "Linking: $src_file -> $target_file"
ln -s "$src_file" "$target_file"
done done
# Handle .config/alacritty/themes directory specially - link the whole directory # For each submodule
if [ -d "$src_dir/.config/alacritty/themes" ]; then for submodule in "${sub_modules[@]}"; do
local target_alacritty_themes="$target_dir/.config/alacritty/themes" # cd into the submodule and git submodule update --init --recursive
cd "$src_dir/$submodule"
# 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 git submodule update --init --recursive
# cd back to the src_dir
# Create symlink for the entire directory cd "$src_dir"
echo "Linking directory: $src_dir/.config/alacritty/themes -> $target_alacritty_themes" done
ln -s "$src_dir/.config/alacritty/themes" "$target_alacritty_themes"
fi
} }

View File

@@ -3,8 +3,8 @@
# Install dependencies # Install dependencies
sudo apt-get update sudo apt-get update
# Python 3 and related packages # Python 3 and dependencies
sudo apt-get install -y python3 python3-pip python3-venv curl wget sudo apt-get install -y python3 python3-pip python3-venv curl wget unzip
# Install most stuff # Install most stuff
sudo apt-get install -y zsh bat fzf jq knot-dnsutils tre-command polybar sudo apt-get install -y zsh bat fzf jq knot-dnsutils tre-command polybar
@@ -25,7 +25,7 @@ curl --proto '=https' --tlsv1.2 -LsSf https://setup.atuin.sh | sh
cargo install eza cargo install eza
# Install Alacritty # Install Alacritty
sudo apt install cmake g++ pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev sudo apt install -y cmake g++ pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev
cargo install alacritty cargo install alacritty
# Add to menu # Add to menu
sudo cp ./alacritty-term.svg /usr/share/pixmaps/Alacritty.svg sudo cp ./alacritty-term.svg /usr/share/pixmaps/Alacritty.svg
@@ -42,4 +42,4 @@ git clone git@woodburn.au:nathanwoodburn/dotfiles.git ~/.dotfiles
git clone git@woodburn.au:nathanwoodburn/scripts.git ~/scripts git clone git@woodburn.au:nathanwoodburn/scripts.git ~/scripts
# Install fonts # Install fonts
sudo apt install fonts-firacode sudo apt install -y fonts-firacode