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
|
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")
|
dirs_to_sym=(".config/alacritty/themes" ".zsh_functions")
|
||||||
sub_modules = (".config/alacritty/themes")
|
sub_modules=(".config/alacritty/themes")
|
||||||
|
ignore_files=("README.md" ".git" ".gitmodules")
|
||||||
|
|
||||||
# Function to create symlinks recursively
|
# Function to create symlinks recursively
|
||||||
create_symlinks() {
|
create_symlinks() {
|
||||||
@ -12,23 +15,38 @@ 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
|
# For each file
|
||||||
for file in "$src_dir"/*; do
|
for file in "$src_dir"/*; do
|
||||||
# Get the file name
|
# Get the file name
|
||||||
local file_name=$(basename "$file")
|
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 the file is a directory
|
||||||
if [ -d "$file" ]; then
|
if [ -d "$file" ]; then
|
||||||
# Check if the directory is in the list of directories to symlink
|
# Check if the directory is in the list of directories to symlink
|
||||||
if [[ " ${dirs_to_sym[@]} " =~ " $file_name " ]]; then
|
if [[ " ${dirs_to_sym[@]} " =~ " $file_name " ]]; then
|
||||||
# If the directory is in the list, create a symlink
|
# For these special directories, create the directory and symlink contents
|
||||||
echo "Linking directory: $file -> $target_dir/$file_name"
|
mkdir -p "$target_dir/$file_name"
|
||||||
ln -s "$file" "$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
|
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"
|
create_symlinks "$file" "$target_dir/$file_name"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# If the file is not a symlink
|
# If the file is not a symlink already
|
||||||
if [ ! -L "$target_dir/$file_name" ]; then
|
if [ ! -L "$target_dir/$file_name" ]; then
|
||||||
# If the file exists
|
# If the file exists
|
||||||
if [ -e "$target_dir/$file_name" ]; then
|
if [ -e "$target_dir/$file_name" ]; then
|
||||||
@ -41,22 +59,9 @@ create_symlinks() {
|
|||||||
ln -s "$file" "$target_dir/$file_name"
|
ln -s "$file" "$target_dir/$file_name"
|
||||||
fi
|
fi
|
||||||
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
|
done
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Call the function to create symlinks from dotfiles to home
|
# Call the function to create symlinks from dotfiles to home
|
||||||
create_symlinks "$HOME/.dotfiles" "$HOME"
|
create_symlinks "$HOME/.dotfiles" "$HOME"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user