-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-symlinks.sh
executable file
·74 lines (57 loc) · 1.39 KB
/
install-symlinks.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#! /bin/bash
set -e
repo_dir=$(realpath "$(dirname "$0")")
create_symlink() {
local target link link_real
if [ ! -e "$1" ]; then
echo "target $1 does not exist"
return 1
fi
target=$(realpath "--relative-to=$(dirname "$2")" "$1")
link=$2
if [ -e "$link" ]; then
link_real=$(realpath "--relative-to=$(dirname "$2")" "$link")
if [ "$target" != "$link_real" ]; then
# something else is already in the location
echo "$link already exists, delete and try again"
return 1
else
echo "symlink $link -> $target already exists"
return 0
fi
else
echo "creating symlink $link -> $target"
mkdir -p "$(dirname "$link")"
ln -s "$target" "$link"
echo "done"
fi
return 0
}
config_dir=$HOME/.config
config_links=(
compton.conf
picom.conf
dunst
i3
i3blocks
i3status
chromium-flags.conf
)
for link in "${config_links[@]}"; do
create_symlink "$repo_dir/$link" "$config_dir/$link"
done
urxvt_dir=$HOME/.urxvt/ext
for ext in "$repo_dir"/urxvt_ext/*; do
ext_name=$(basename "$ext")
create_symlink "$ext" "$urxvt_dir/$ext_name"
done
home_links=(
.bashrc
.inputrc
.bash_aliases
.Xdefaults
.gitconfig
)
for link in "${home_links[@]}"; do
create_symlink "$repo_dir/$link" "$HOME/$link"
done