diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-10-22 22:50:02 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-10-22 22:50:02 +0200 |
| commit | a4f18086ba7ce108ebb041b9b0c52bf522413000 (patch) | |
| tree | 8d63a98b329f4af486f38db47d0b6049c6e441d8 /.scripts/dotfiles.sh | |
| parent | bf45ef759815ad7ac3f6423114a96f4d56d1a2a2 (diff) | |
| parent | 68a2612c8b737f6770a4d23848fe6409ddce7888 (diff) | |
| download | dotfiles-a4f18086ba7ce108ebb041b9b0c52bf522413000.tar.gz dotfiles-a4f18086ba7ce108ebb041b9b0c52bf522413000.zip | |
Add '.scripts/' from commit 'a4ba0376ba73b1bb295d8bb459a4bf2b063ddca9'
git-subtree-dir: .scripts
git-subtree-mainline: 03c0cf66468d5e04c0e3559f9f89b5eec28feb9e
git-subtree-split: a4ba0376ba73b1bb295d8bb459a4bf2b063ddca9
Diffstat (limited to '.scripts/dotfiles.sh')
| -rwxr-xr-x | .scripts/dotfiles.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/.scripts/dotfiles.sh b/.scripts/dotfiles.sh new file mode 100755 index 0000000..b231367 --- /dev/null +++ b/.scripts/dotfiles.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Set the bare dotfiles repo directory +dotfiles_dir="$HOME/.cfg" + +# Set the home directory +home_dir="$HOME" + +# Exclude the .cfg directory and any other files/directories you want to ignore +exclude_list=(".cfg") + +# Change to the home directory +cd "$home_dir" + +# Get a list of all dotfiles in the repository +files=$(find "$dotfiles_dir" -maxdepth 1 -type f -not -name ".*" -not -name "${exclude_list[*]}" -printf "%f\n") + +# Link each file to its corresponding location in $HOME +for file in $files; do + ln -sf "$dotfiles_dir/$file" "$home_dir/.$file" +done + +# Get a list of all dot directories in the repository +dirs=$(find "$dotfiles_dir" -maxdepth 1 -type d -not -path "$dotfiles_dir" -not -name ".*" -not -name "${exclude_list[*]}" -printf "%f\n") + +# Link each directory to its corresponding location in $HOME +for dir in $dirs; do + ln -sf "$dotfiles_dir/$dir" "$home_dir/.$dir" +done + +# Remove any symlinks that are no longer present in the repo +while IFS= read -r -d '' link; do + if [[ ! -e "$link" ]]; then + rm "$link" + fi +done < <(find "$home_dir" -maxdepth 1 -type l -name ".*" -not -name ".cfg" -print0) + |
