63 lines
2.0 KiB
Bash
Executable File
63 lines
2.0 KiB
Bash
Executable File
cd ~/.dotfiles
|
|
git pull
|
|
echo "Creating symbolic links for dotfiles..."
|
|
|
|
dirs_to_sym = (".config/alacritty/themes" ".zsh_functions")
|
|
sub_modules = (".config/alacritty/themes")
|
|
|
|
# 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"
|
|
# For each file
|
|
for file in "$src_dir"/*; do
|
|
# Get the file name
|
|
local file_name=$(basename "$file")
|
|
# If the file is a directory
|
|
if [ -d "$file" ]; then
|
|
# Check if the directory is in the list of directories to symlink
|
|
if [[ " ${dirs_to_sym[@]} " =~ " $file_name " ]]; then
|
|
# 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
|
|
else
|
|
# If the file is not a symlink
|
|
if [ ! -L "$target_dir/$file_name" ]; then
|
|
# 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
|
|
done
|
|
|
|
# For each submodule
|
|
for submodule in "${sub_modules[@]}"; do
|
|
# cd into the submodule and git submodule update --init --recursive
|
|
cd "$src_dir/$submodule"
|
|
git submodule update --init --recursive
|
|
# cd back to the src_dir
|
|
cd "$src_dir"
|
|
done
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# Call the function to create symlinks from dotfiles to home
|
|
create_symlinks "$HOME/.dotfiles" "$HOME"
|
|
|
|
echo "Dotfiles setup complete!" |