-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap_castle.sh
More file actions
executable file
·38 lines (33 loc) · 921 Bytes
/
bootstrap_castle.sh
File metadata and controls
executable file
·38 lines (33 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env zsh
#
# Symlinks files recursively from castle directory to
# your home directory. Will also ensure that directories
# in castle is created at home directory.
setopt extended_glob
dotfiles_dir=$(cd "$( dirname "$0" )" && pwd)
source ./scripts/funcs.sh
castle=$dotfiles_dir/castle
dotfiles=("${(@f)$(cd $castle; printf '%s\n' **/*~*swp(D:^M))}")
backup=$HOME/dotfiles_backup
for file in $dotfiles; do
if [ -d $castle/$file ]; then
mkdir -p $HOME/$file
mkdir -p $backup/$file
continue
fi
if [ -L $HOME/$file ]; then
if [ "$HOME/$file" -ef "$castle/$file" ]; then
ok $file
continue
fi
warn "$HOME/$file does not point to $castle/$file. Removing it."
rm $HOME/$file
fi
if [ -f $HOME/$file ]; then
echo "Backing up $HOME/$file"
mv -v $HOME/$file $backup/$file
fi
echo "Symlinking $HOME/$file"
ln -vs $castle/$file $HOME/$file
ok $file
done