fix: Try new dotfiles importer
This commit is contained in:
parent
b31334a1c1
commit
b58bcb5f81
45
dotfiles.sh
45
dotfiles.sh
@ -1,9 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd ~/.dotfiles
|
||||
git pull
|
||||
echo "Creating symbolic links for dotfiles..."
|
||||
|
||||
dirs_to_sym = (".config/alacritty/themes" ".zsh_functions")
|
||||
sub_modules = (".config/alacritty/themes")
|
||||
dirs_to_sym=(".config/alacritty/themes" ".zsh_functions")
|
||||
sub_modules=(".config/alacritty/themes")
|
||||
ignore_files=("README.md" ".git" ".gitmodules")
|
||||
|
||||
# Function to create symlinks recursively
|
||||
create_symlinks() {
|
||||
@ -12,23 +15,38 @@ create_symlinks() {
|
||||
|
||||
# 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")
|
||||
|
||||
# Check if file should be ignored
|
||||
if [[ " ${ignore_files[@]} " =~ " $file_name " ]]; then
|
||||
echo "Ignoring: $file_name"
|
||||
continue
|
||||
fi
|
||||
|
||||
# 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"
|
||||
# For these special directories, create the directory and symlink contents
|
||||
mkdir -p "$target_dir/$file_name"
|
||||
# If this directory is also a submodule, initialize it
|
||||
if [[ " ${sub_modules[@]} " =~ " $file_name " ]]; then
|
||||
echo "Initializing submodule: $file_name"
|
||||
(cd "$file" && git submodule update --init --recursive)
|
||||
fi
|
||||
# Recursively create symlinks for the contents
|
||||
create_symlinks "$file" "$target_dir/$file_name"
|
||||
else
|
||||
# If the directory is not in the list, recursively call the function
|
||||
# For regular directories, create them and recurse
|
||||
mkdir -p "$target_dir/$file_name"
|
||||
create_symlinks "$file" "$target_dir/$file_name"
|
||||
fi
|
||||
else
|
||||
# If the file is not a symlink
|
||||
# If the file is not a symlink already
|
||||
if [ ! -L "$target_dir/$file_name" ]; then
|
||||
# If the file exists
|
||||
if [ -e "$target_dir/$file_name" ]; then
|
||||
@ -42,21 +60,8 @@ create_symlinks() {
|
||||
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"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user