Recursive install script

This commit is contained in:
Augusto Gunsch 2021-08-20 14:40:35 -03:00
parent fb86f77ff8
commit 20325870e2
No known key found for this signature in database
GPG Key ID: F7EEFE29825C72DC
1 changed files with 16 additions and 18 deletions

View File

@ -1,25 +1,23 @@
#!/bin/sh
set -e
cd "$(dirname "$0")"
PWD="$(pwd)"
#dotfiles from
#~/.config
for f in config/*; do
mkdir -p "$HOME/.$f"
for d in $f/*; do
ln -sf "$PWD/$d" "$HOME/.$d"
done
done
#dir to
clone_dir() {
local dir=${1:-home}
local to=${2:-$HOME}
#dotfiles from
#~
for f in home/*; do
ln -sf "$PWD/$f" "$HOME/.$(basename $f)"
mkdir -p "$to/.${dir#home}"
for f in $dir/*; do
if [ -d "$f" ]; then
clone_dir "$f" "$to"
elif [ -f "$f" ]; then
ln -sf '$PWD/$f' -> '$to/.${f#home/}'
fi
done
}
#scripts
#~/.local/bin
mkdir -p "$HOME/.local/bin"
for f in local/bin/*; do
ln -sf "$PWD/$f" "$HOME/.$f"
for d in */; do
clone_dir "${d%/}"
done