-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup
executable file
·98 lines (85 loc) · 2.45 KB
/
setup
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
98
#!/usr/bin/env zsh
DOTFILES=$HOME/.dotfiles
setup_link() {
src="$DOTFILES/$1"
dst="$HOME/$2"
if [ "$src" -ef "$dst" ]; then
return
fi
if [[ -f "$dst" || -h "$dst" ]]; then
>&2 echo "WARNING: $dst exists, overwriting"
rm -f "$dst"
fi
echo "$src -> $dst"
ln -s $src $dst
}
link_role() {
echo "Adding role $1"
role_dir=roles/$1
if [ ! -d $DOTFILES/$role_dir ]; then
echo "ERROR: No role dir at $role_dir"
return
fi
setup_file=$DOTFILES/$role_dir/setup
if [ -f $setup_file ]; then
source $setup_file
fi
zsh_plugin_file="$role_dir/zsh_plugin"
if [ -f $DOTFILES/$zsh_plugin_file ]; then
setup_link $zsh_plugin_file ".zsh/plugins/$1.zsh"
fi
}
mkdir -p $HOME/.gradle
setup_link "gradle/properties" ".gradle/gradle.properties"
setup_link "zsh/zshrc" ".zshrc"
mkdir -p $HOME/.zsh
mkdir -p $HOME/.zsh/var/
mkdir -p $HOME/.zsh/plugins/
# clear any existing plugin links
rm -f $HOME/.zsh/plugins/*
setup_link "zsh/p10k.zsh" ".zsh/p10k.zsh"
for ZSH_PLUGIN in $DOTFILES/zsh/plugins/*; do
NAME=$(basename $ZSH_PLUGIN)
setup_link "zsh/plugins/$NAME" ".zsh/plugins/$NAME"
done
roles=$DOTFILES/hosts/$(hostname)/roles
if [ ! -f $roles ]; then
roles=$HOME/.zshroles
fi
if [ -f $roles ]; then
while read role; do
link_role $role
done <$roles
fi
mkdir -p $HOME/.ssh
setup_link "ssh/config" ".ssh/config"
ssh_host_config=hosts/$(hostname)/ssh_host_config
if [ -f $DOTFILES/$ssh_host_config ]; then
setup_link "$ssh_host_config" ".ssh/host_config"
fi
mkdir -p $HOME/.vim
for VIMFILE in $DOTFILES/vim/*; do
NAME=$(basename $VIMFILE)
setup_link "vim/$NAME" ".vim/$NAME"
done
mkdir -p $HOME/.git
setup_link "git/config" ".gitconfig"
setup_link "git/ignore" ".git/ignore"
if [[ $OSTYPE == darwin* ]]; then
brewfile=hosts/$(hostname)/brewfile
if [ -f $DOTFILES/$brewfile ]; then
setup_link "$brewfile" ".Brewfile"
else
touch $HOME/.Brewfile
fi
if [ -f $DOTFILES/$brewfile-x86 ]; then
setup_link "$brewfile-x86" ".Brewfile-x86"
fi
# symlink icloud drive to homedir
if [ ! -d $HOME/iCloud ]; then
ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs ~/iCloud
fi
fi
echo ""
echo "Config files are setup."
echo "Run 'reload-config' to re-source zsh config."