sunhat/install/dotfiles.sh

37 lines
763 B
Bash
Raw Normal View History

2024-05-25 21:28:50 -05:00
# Ensure .config exists
mkdir -p ~/.config
# Link all dotfiles
2024-05-26 21:47:00 -05:00
for entry in ~/.local/share/omakub/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-26 21:47:00 -05:00
if [ -f $entry ]; then
target=~/."$(basename $entry)"
2024-05-26 18:09:34 -05:00
2024-05-26 21:47:00 -05:00
if [ -e $target ] && [ "$(readlink $target)" != $entry ]; then
mv $target $target.bak
2024-05-26 18:09:34 -05:00
fi
2024-05-26 21:47:00 -05:00
if [ ! -e $target ]; then
ln -s $entry $target
2024-05-26 18:09:34 -05:00
fi
touch $entry.local
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-26 21:47:00 -05:00
if [ -d $entry ]; then
target=~/.config/"$(basename $entry)"
2024-05-26 18:09:34 -05:00
2024-05-26 21:47:00 -05:00
if [ -e $target ] && [ "$(readlink "$target")" != $entry ]; then
mv $target $target.bak
2024-05-26 18:09:34 -05:00
fi
2024-05-26 21:47:00 -05:00
if [ ! -e $target ]; then
ln -s $entry $target
2024-05-26 18:09:34 -05:00
fi
2024-05-25 21:28:50 -05:00
fi
done
unset entry