sunhat/install/dotfiles.sh

35 lines
785 B
Bash
Raw Normal View History

2024-05-25 21:28:50 -05:00
# Ensure .config exists
mkdir -p ~/.config
# Link all dotfiles
for entry in dotfiles/*; do
2024-05-25 21:46:14 -05:00
# Link all root files as .file in ~/
# Any existing files will be renamed .bak
2024-05-25 21:28:50 -05:00
if [ -f "$entry" ]; then
2024-05-25 21:46:14 -05:00
target=~/."$(basename "$entry")"
2024-05-26 18:09:34 -05:00
if [ -e "$target" ] && [ "$(readlink "$target")" != "$(pwd)/$entry" ]; then
mv "$target" "$target.bak"
fi
if [ ! -e "$target" ]; then
ln -s "$(pwd)/$entry" "$target"
fi
2024-05-25 21:28:50 -05:00
fi
2024-05-25 21:46:14 -05:00
# Link all directories in ~/.config/
# Any existing directories will be renamed .bak
2024-05-25 21:28:50 -05:00
if [ -d "$entry" ]; then
target=~/.config/"$(basename "$entry")"
2024-05-26 18:09:34 -05:00
if [ -e "$target" ] && [ "$(readlink "$target")" != "$(pwd)/$entry" ]; then
mv "$target" "$target.bak"
fi
if [ ! -e "$target" ]; then
ln -s "$(pwd)/$entry" "$target"
fi
2024-05-25 21:28:50 -05:00
fi
done
unset entry