-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall
executable file
·97 lines (85 loc) · 1.94 KB
/
install
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
cd "$(dirname "$0")" || exit
DOTFILES=~/.dotfiles
(cd $DOTFILES && git pull)
link_dotfile() {
if [ "$1" = "." ] || [ "$1" = ".." ]; then
return
fi
if [ -h "$HOME/$1" ]; then
echo "skipping $1 (link) "
return
fi
if [ -f "$HOME/$1" ]; then
echo "skipping $1 (file) "
return
fi
if [ -d "$HOME/$1" ]; then
echo "skipping $1 (dir) "
return
fi
if [ ".config" = "$1" ]; then
echo "skipping $1 (.config) "
return
fi
case "$1" in
*.git | .gitignore | ".|.." | .vscode | .sonarlint) return ;;
esac
echo "$PWD/$1"
echo "linking $PWD/$1 -> $HOME/$1"
ln -s "$PWD/$1" "$HOME/$1"
}
link_confdir() {
if [ ! -e "$HOME/.config" ]; then
echo "creating ~/.config"
mkdir "$HOME/.config"
fi
if [ -e "$HOME/.config/$1" ]; then
echo "rm ~/.config/$1"
rm -rf "$HOME/.config/$1"
fi
echo "linking $PWD/$1 --> ~/.config/$1"
ln -s "$PWD/$1" "$HOME/.config/$1"
}
install_dotfiles() {
[ ! -e "$DOTFILES" ] && return
echo "installing from $DOTFILES..."
(
cd "$DOTFILES" || exit
for file in .*; do
link_dotfile "$file"
done
)
}
install_confdirs() {
(
cd config || exit
for confdir in *; do
link_confdir "$confdir"
done
)
}
install_brewfile() {
if [ -e /Library ] && [ ! -e "$HOME/Brewfile" ]; then
echo "linking Brewfile $DOTFILES/Brewfile -> ~/Brewfile"
ln -s "$DOTFILES/Brewfile" "$HOME/Brewfile"
fi
}
install_gitconfig() {
if ! grep '.dotfiles' ~/.gitconfig >/dev/null; then
echo "Adding ~/.dotfiles/git.d/*.conf to ~/.gitconfig"
printf "\n[include]\npath = ~/.dotfiles/git.d/*.conf\n" >>~/.gitconfig
fi
}
install_sshconfig() {
if ! grep '.dotfiles' ~/.ssh/config >/dev/null; then
echo "Adding ~/.dotfiles/ssh.d/*.conf to ~/.ssh/config"
printf "\nInclude ~/.dotfiles/ssh.d/*.conf\n" >>~/.ssh/config
fi
}
install_dotfiles
install_confdirs
install_brewfile
install_sshconfig
install_gitconfig
cd - >/dev/null || exit