35 lines
785 B
Bash
35 lines
785 B
Bash
# Ensure .config exists
|
|
mkdir -p ~/.config
|
|
|
|
# Link all dotfiles
|
|
for entry in dotfiles/*; do
|
|
# Link all root files as .file in ~/
|
|
# Any existing files will be renamed .bak
|
|
if [ -f "$entry" ]; then
|
|
target=~/."$(basename "$entry")"
|
|
|
|
if [ -e "$target" ] && [ "$(readlink "$target")" != "$(pwd)/$entry" ]; then
|
|
mv "$target" "$target.bak"
|
|
fi
|
|
|
|
if [ ! -e "$target" ]; then
|
|
ln -s "$(pwd)/$entry" "$target"
|
|
fi
|
|
fi
|
|
|
|
# Link all directories in ~/.config/
|
|
# Any existing directories will be renamed .bak
|
|
if [ -d "$entry" ]; then
|
|
target=~/.config/"$(basename "$entry")"
|
|
|
|
if [ -e "$target" ] && [ "$(readlink "$target")" != "$(pwd)/$entry" ]; then
|
|
mv "$target" "$target.bak"
|
|
fi
|
|
|
|
if [ ! -e "$target" ]; then
|
|
ln -s "$(pwd)/$entry" "$target"
|
|
fi
|
|
fi
|
|
done
|
|
unset entry
|