-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
44 lines (40 loc) · 795 Bytes
/
install.sh
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
39
40
41
42
43
44
# thanks, https://github.com/brenns10/dotfiles/blob/master/setup
LINKS=(
.config/mc
.config/nano
.config/alacritty.yml
.irssi
.zsh
.bashrc
.digrc
.nanorc
.profile
.screenrc
.tmux.conf
.vimrc
.zprofile
.zshrc
)
create_symlink() {
# directory removal isn't automated.
# tough, I've been bitten too many times.
rm -f "$HOME/$1"
mkdir -p "$(dirname "$HOME/$1")"
ln -s "$(pwd)/$1" "$HOME/$1"
}
# if the file/directory exists, back it up
# imperfect (e.g. `.config/mc` is backed up to `.backup/mc`).
# whatever, close enough.
backup() {
if [ -f "$1" ] || [ -d "$1" ]; then
cp -a "$1" "${HOME}/.backup/"
fi
}
git submodule init
git submodule update
mkdir -p "${HOME}/.backup"
for item in "${LINKS[@]}"
do
backup "$item"
create_symlink "$item"
done