forked from sontek/homies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·52 lines (41 loc) · 896 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
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
function link_file {
source="${PWD}/$1"
target_name="${1/_/.}"
target="${HOME}/${target_name}"
info "Linking" "$source" "~/$target_name"
if [ -e "${target}" ]; then
if [ -L "${target}" ]; then
unlink $target
else
mv $target $target.df.bak
fi
fi
ln -sf ${source} ${target}
}
function unlink_file {
source="${PWD}/$1"
target_name="${1/_/.}"
target="${HOME}/${target_name}"
info "Unlinking" "$source" "~/$target_name"
if [ -e "${target}.df.bak" ] && [ -L "${target}" ]; then
unlink ${target}
mv $target.df.bak $target
fi
}
function info {
echo "$1: '$3' --> '$2'"
}
if [ "$1" = "restore" ]; then
for i in _*
do
unlink_file $i
done
exit
else
for i in _*
do
link_file $i
done
~/.i3/reload-config.sh
fi